From 70b47d480ff236c8e839711400ec373ccd4f9b40 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Tue, 24 Jul 2018 10:52:09 +0200 Subject: `chain.from_iterable` no longer emits `dict-{}-not-iterating` when dealing with dict values and keys --- ChangeLog | 3 ++- pylint/checkers/python3.py | 3 ++- pylint/test/unittest_checker_python3.py | 5 +++++ 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 = __({}())', -- cgit v1.2.1