-
-
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.
Treat AsyncFunctionDef just like FunctionDef nodes
When support for Python 3.5 was added, AsyncFunctionDef wasn't handled properly in terms of FunctionDef, which meant that most of the checks which involved a function were never called for AsyncFunctionDef. This led to spurious false positives which occurred when AsyncFunctionDef were analyzed. Closes #767
- Loading branch information
1 parent
d2a7144
commit e00abd9
Showing
11 changed files
with
109 additions
and
3 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
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,65 @@ | ||
"""Check that Python 3.5's async functions are properly analyzed by Pylint.""" | ||
# pylint: disable=missing-docstring,invalid-name,too-few-public-methods | ||
# pylint: disable=using-constant-test | ||
|
||
async def next(): # [redefined-builtin] | ||
pass | ||
|
||
async def some_function(arg1, arg2): # [unused-argument] | ||
await arg1 | ||
|
||
|
||
class OtherClass(object): | ||
|
||
@staticmethod | ||
def test(): | ||
return 42 | ||
|
||
|
||
class Class(object): | ||
|
||
async def some_method(self): | ||
super(OtherClass, self).test() # [bad-super-call] | ||
|
||
|
||
# +1: [too-many-arguments,too-many-return-statements, too-many-branches] | ||
async def complex_function(this, function, has, more, arguments, than, | ||
one, _, should, have): | ||
if 1: | ||
return this | ||
elif 1: | ||
return function | ||
elif 1: | ||
return has | ||
elif 1: | ||
return more | ||
elif 1: | ||
return arguments | ||
elif 1: | ||
return than | ||
try: | ||
return one | ||
finally: | ||
pass | ||
if 2: | ||
return should | ||
while True: | ||
pass | ||
if 1: | ||
return have | ||
elif 2: | ||
return function | ||
elif 3: | ||
pass | ||
|
||
|
||
# +1: [duplicate-argument-name,dangerous-default-value] | ||
async def func(a, a, b=[]): | ||
return a, b | ||
|
||
|
||
# +1: [empty-docstring, blacklisted-name] | ||
async def foo(): | ||
"" | ||
|
||
|
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.5 |
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,10 @@ | ||
redefined-builtin:5:next:"Redefining built-in 'next'" | ||
unused-argument:8:some_function:"Unused argument 'arg2'" | ||
bad-super-call:22:Class.some_method:"Bad first argument 'OtherClass' given to super()" | ||
too-many-arguments:26:complex_function:Too many arguments (10/5) | ||
too-many-branches:26:complex_function:Too many branches (13/12) | ||
too-many-return-statements:26:complex_function:Too many return statements (10/6) | ||
dangerous-default-value:57:func:Dangerous default value [] as argument | ||
duplicate-argument-name:57:func:Duplicate argument name a in function definition | ||
blacklisted-name:62:foo:Black listed name "foo" | ||
empty-docstring:62:foo:Empty function docstring |
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