summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-07-24 10:52:09 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-07-24 10:59:29 +0200
commit70b47d480ff236c8e839711400ec373ccd4f9b40 (patch)
tree6bed0befbe7242aeb3f51c3ec219b65b650ec454
parent10b97722edf5eba36efdf27cd374753ea06392d6 (diff)
downloadpylint-git-70b47d480ff236c8e839711400ec373ccd4f9b40.tar.gz
`chain.from_iterable` no longer emits `dict-{}-not-iterating` when dealing with dict values and keys
-rw-r--r--ChangeLog3
-rw-r--r--pylint/checkers/python3.py3
-rw-r--r--pylint/test/unittest_checker_python3.py5
3 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c19bff86..dfc12bd23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,9 +5,10 @@ Pylint's ChangeLog
What's New in Pylint 1.9.3?
===========================
-
Release date: |TBA|
+ * `chain.from_iterable` no longer emits `dict-{}-not-iterating` when dealing with dict values and keys
+
* Fix incorrect file path when file absolute path contains multiple ``path_strip_prefix`` strings.
Close #1120 and #2280
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index 63e756fb7..006f2d7b0 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -80,6 +80,7 @@ def _is_builtin(node):
_ACCEPTS_ITERATOR = {'iter', 'list', 'tuple', 'sorted', 'set', 'sum', 'any',
'all', 'enumerate', 'dict', 'filter', 'reversed',
'max', 'min', 'frozenset'}
+ATTRIBUTES_ACCEPTS_ITERATOR = {'join', 'from_iterable'}
_BUILTIN_METHOD_ACCEPTS_ITERATOR = {
'builtins.list.extend',
'builtins.dict.update',
@@ -112,7 +113,7 @@ def _in_iterating_context(node):
if _is_builtin(parent_scope) and parent.func.name in _ACCEPTS_ITERATOR:
return True
elif isinstance(parent.func, astroid.Attribute):
- if parent.func.attrname == 'join':
+ if parent.func.attrname in ATTRIBUTES_ACCEPTS_ITERATOR:
return True
try:
inferred = next(parent.func.infer())
diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py
index ee0db32d2..59d1b2a22 100644
--- a/pylint/test/unittest_checker_python3.py
+++ b/pylint/test/unittest_checker_python3.py
@@ -211,6 +211,11 @@ class TestPython3Checker(testutils.CheckerTestCase):
'set().update({}())',
'[].extend({}())',
'{{}}.update({}())',
+ '''
+ from __future__ import absolute_import
+ from itertools import chain
+ chain.from_iterable({}())
+ ''',
]
non_iterating_code = [
'x = __({}())',