-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false-positive for unused-import on class keyword arguments
- Loading branch information
1 parent
12acc43
commit 7905ec1
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/functional/u/unused/unused_import_class_def_keyword.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Test false-positive for unused-import on class keyword arguments | ||
https://github.com/PyCQA/pylint/issues/3202 | ||
""" | ||
# pylint: disable=missing-docstring,too-few-public-methods,invalid-name,import-error | ||
|
||
# Imports don't exist! Only check `unused-import` | ||
from const import DOMAIN | ||
from const import DOMAIN_2 | ||
from const import DOMAIN_3 | ||
|
||
|
||
class Child: | ||
def __init_subclass__(cls, **kwargs): | ||
pass | ||
|
||
class Parent(Child, domain=DOMAIN): | ||
pass | ||
|
||
|
||
# Alternative 1 | ||
class Parent_2(Child, domain=DOMAIN_2): | ||
DOMAIN_2 = DOMAIN_2 | ||
|
||
|
||
# Alternative 2 | ||
class A: | ||
def __init__(self, arg): | ||
pass | ||
|
||
class B: | ||
CONF = "Hello World" | ||
SCHEMA = A(arg=CONF) | ||
|
||
|
||
# Test normal instantiation | ||
A(arg=DOMAIN_3) |