Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: flake8-abp/flake8_abp.py

Issue 29344615: Noissue - Allow calling map() with lambda and multiple sequences (Closed)
Patch Set: Created May 26, 2016, 2:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | flake8-abp/tests/A104.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: flake8-abp/flake8_abp.py
===================================================================
--- a/flake8-abp/flake8_abp.py
+++ b/flake8-abp/flake8_abp.py
@@ -284,13 +284,14 @@
arg = next(iter(node.args), None)
redundant_literal = False
- if isinstance(arg, ast.Lambda) and func in {'map', 'filter',
- 'imap', 'ifilter',
- 'itertools.imap',
- 'itertools.ifilter'}:
- self.errors.append((node, 'A104 use a comprehension '
- 'instead of calling {}() with '
- 'lambda function'.format(func)))
+ if isinstance(arg, ast.Lambda):
+ if len(node.args) == 2 and func in {'map', 'filter',
+ 'imap', 'ifilter',
+ 'itertools.imap',
+ 'itertools.ifilter'}:
+ self.errors.append((node, 'A104 use a comprehension '
+ 'instead of calling {}() with '
+ 'lambda function'.format(func)))
elif isinstance(arg, (ast.List, ast.Tuple)):
if func == 'dict':
redundant_literal = all(isinstance(elt, (ast.Tuple, ast.List))
« no previous file with comments | « no previous file | flake8-abp/tests/A104.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld