diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-09-05 17:09:09 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-09-05 17:09:09 +0300 |
commit | cb3dc3eb10d0c315170ed7a826ac268af9ef8bca (patch) | |
tree | b1ac490955b84e00a027c158070f357adfdba4eb | |
parent | 4a1c791a46d90d8ef2d74cc8fbd291fc1b52deb6 (diff) | |
download | pylint-cb3dc3eb10d0c315170ed7a826ac268af9ef8bca.tar.gz |
Fix false positives with unnecessary-lambda. Closes issue #630.
-rw-r--r-- | pylint/checkers/base.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index e8c9aa7..e70641f 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -746,20 +746,14 @@ functions, methods # The body of the lambda must be a function call expression # for the lambda to be unnecessary. return - # XXX are lambda still different with astroid >= 0.18 ? - # *args and **kwargs need to be treated specially, since they - # are structured differently between the lambda and the function - # call (in the lambda they appear in the args.args list and are - # indicated as * and ** by two bits in the lambda's flags, but - # in the function call they are omitted from the args list and - # are indicated by separate attributes on the function call node). + ordinary_args = list(node.args.args) if node.args.kwarg: if (not call.kwargs or not isinstance(call.kwargs, astroid.Name) or node.args.kwarg != call.kwargs.name): return - elif call.kwargs: + elif call.kwargs or call.keywords: return if node.args.vararg: if (not call.starargs @@ -772,12 +766,6 @@ functions, methods # ordinary_args[i].name == call.args[i].name. if len(ordinary_args) != len(call.args): return - # Verify that the call uses keyword values that aren't - # defined by the lambda arguments. - for kwarg in call.keywords or []: - if (not node.args.parent_of(kwarg.value) - and not isinstance(kwarg.value, astroid.Const)): - return for i in range(len(ordinary_args)): if not isinstance(call.args[i], astroid.Name): |