Skip to content

Commit 570e655

Browse files
tiagohonoratoPierre-Sassoulas
authored andcommitted
Fix false positive when map() receives iterable
Since map() supports iterables, it should not issue builtin-not-iterating for iterable arguments. Signed-off-by: Tiago Honorato <[email protected]>
1 parent ba6a403 commit 570e655

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

CONTRIBUTORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,5 @@ contributors:
445445
* Marc Mueller (cdce8p): contributor
446446

447447
* David Gilman: contributor
448+
449+
* Tiago Honorato: contributor

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Pylint's ChangeLog
55
What's New in Pylint 2.7.0?
66
===========================
77

8+
* Fix false positive for ``builtin-not-iterating`` when ``map`` receives iterable
9+
10+
Closes #4078
11+
812
* Python 3.6+ is now required.
913

1014
* Fix false positive for ``builtin-not-iterating`` when ``zip`` receives iterable

doc/whatsnew/2.7.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ New checkers
2929
Other Changes
3030
=============
3131

32-
* Fix false positive for ``builtin-not-iterating`` when ``zip`` receives iterable
32+
* Fix false positive for ``builtin-not-iterating`` when ``zip`` or ``map`` receives iterable
3333

3434
* Fix linter multiprocessing pool shutdown which triggered warnings when runned in parallels with other pytest plugins.
3535

pylint/checkers/python3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def _is_builtin(node):
9797
"frozenset",
9898
"OrderedDict",
9999
"zip",
100+
"map",
100101
}
101102
ATTRIBUTES_ACCEPTS_ITERATOR = {"join", "from_iterable"}
102103
_BUILTIN_METHOD_ACCEPTS_ITERATOR = {

tests/checkers/unittest_python3.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ def as_argument_to_zip_test(self, fxn):
187187
with self.assertNoMessages():
188188
self.walk(module)
189189

190+
def as_argument_to_map_test(self, fxn):
191+
module = astroid.parse(f"list(map(__, {fxn}()))")
192+
with self.assertNoMessages():
193+
self.walk(module)
194+
190195
def as_iterable_in_unpacking(self, fxn):
191196
node = astroid.extract_node(
192197
f"""
@@ -224,7 +229,7 @@ def iterating_context_tests(self, fxn):
224229
self.as_iterable_in_starred_context(fxn)
225230
self.as_argument_to_itertools_functions(fxn)
226231
self.as_argument_to_zip_test(fxn)
227-
232+
self.as_argument_to_map_test(fxn)
228233
for func in (
229234
"iter",
230235
"list",

0 commit comments

Comments
 (0)