-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take into account
__class_getitem__
from PEP 560 and fixes some false
positives for `no-self-argument` and `unsubscriptable-object`. https://www.python.org/dev/peps/pep-0560/ Fixes #2416
- Loading branch information
Showing
9 changed files
with
40 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Test detection of self as argument of first method in Python 3.7 and above.""" | ||
|
||
# pylint: disable=missing-docstring,too-few-public-methods,useless-object-inheritance | ||
|
||
|
||
class Toto(object): | ||
|
||
def __class_getitem__(cls, params): | ||
# This is actually a special method which is always a class method. | ||
# See https://www.python.org/dev/peps/pep-0560/#class-getitem | ||
pass | ||
|
||
def __class_other__(cls, params): # [no-self-argument] | ||
# This is not a special case and as such is an instance method. | ||
pass |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.7 |
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 @@ | ||
no-self-argument:13:Toto.__class_other__:Method should have "self" as first argument |
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,14 @@ | ||
""" | ||
Checks that class used in a subscript supports subscription | ||
(i.e. defines __class_getitem__ method). | ||
""" | ||
# pylint: disable=missing-docstring,pointless-statement,expression-not-assigned,wrong-import-position | ||
# pylint: disable=too-few-public-methods,import-error,invalid-name,wrong-import-order, useless-object-inheritance | ||
class Subscriptable(object): | ||
|
||
def __class_getitem__(cls, params): | ||
pass | ||
|
||
|
||
Subscriptable[0] | ||
Subscriptable()[0] # [unsubscriptable-object] |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.7 |
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 @@ | ||
unsubscriptable-object:14::Value 'Subscriptable()' is unsubscriptable |