summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiagohonorato <61059243+tiagohonorato@users.noreply.github.com>2021-02-19 19:24:07 -0300
committerGitHub <noreply@github.com>2021-02-19 23:24:07 +0100
commitbad6eec57ff001e8af66dfeee14ce250df709124 (patch)
tree0a0edc528e43ec2d2dcc34c72eaba4f48291e147
parentf9b2227cb036349dda36101d904496e2b54167e8 (diff)
downloadpylint-git-bad6eec57ff001e8af66dfeee14ce250df709124.tar.gz
Fix false positive when zip() receives iterable (#4105)
Since zip() supports iterables, it should not be an issue builtin-not-iterating for iterable arguments. Signed-off-by: Tiago Honorato <tiagohonorato1@gmail.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--ChangeLog6
-rw-r--r--doc/whatsnew/2.7.rst2
-rw-r--r--pylint/checkers/python3.py1
-rw-r--r--tests/checkers/unittest_python3.py6
4 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f3badb564..150c4fb7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,10 +5,12 @@ Pylint's ChangeLog
What's New in Pylint 2.7.0?
===========================
-* Add `nan-comparison` check for NaN comparisons
-
* Python 3.6+ is now required.
+* Fix false positive for ``builtin-not-iterating`` when ``zip`` receives iterable
+
+* Add `nan-comparison` check for NaN comparisons
+
* Bug fix for empty-comment message line number.
Closes #4009
diff --git a/doc/whatsnew/2.7.rst b/doc/whatsnew/2.7.rst
index 1f7bab85a..154e510a5 100644
--- a/doc/whatsnew/2.7.rst
+++ b/doc/whatsnew/2.7.rst
@@ -29,6 +29,8 @@ New checkers
Other Changes
=============
+* Fix false positive for ``builtin-not-iterating`` when ``zip`` receives iterable
+
* Fix linter multiprocessing pool shutdown which triggered warnings when runned in parallels with other pytest plugins.
* Enums are now required to be named in UPPER_CASE by ``invalid-name``.
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index 9b46c1fe1..ac2752d27 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -96,6 +96,7 @@ _ACCEPTS_ITERATOR = {
"min",
"frozenset",
"OrderedDict",
+ "zip",
}
ATTRIBUTES_ACCEPTS_ITERATOR = {"join", "from_iterable"}
_BUILTIN_METHOD_ACCEPTS_ITERATOR = {
diff --git a/tests/checkers/unittest_python3.py b/tests/checkers/unittest_python3.py
index cbb4fbb20..9c46f4fa8 100644
--- a/tests/checkers/unittest_python3.py
+++ b/tests/checkers/unittest_python3.py
@@ -182,6 +182,11 @@ class TestPython3Checker(testutils.CheckerTestCase):
with self.assertNoMessages():
self.walk(module)
+ def as_argument_to_zip_test(self, fxn):
+ module = astroid.parse(f"list(zip({fxn}))")
+ with self.assertNoMessages():
+ self.walk(module)
+
def as_iterable_in_unpacking(self, fxn):
node = astroid.extract_node(
f"""
@@ -218,6 +223,7 @@ class TestPython3Checker(testutils.CheckerTestCase):
self.as_iterable_in_yield_from(fxn)
self.as_iterable_in_starred_context(fxn)
self.as_argument_to_itertools_functions(fxn)
+ self.as_argument_to_zip_test(fxn)
for func in (
"iter",