summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-06-14 08:13:31 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-06-14 08:13:31 +0200
commit5bcdf822c328c4f2878fd4e54490bfee7e1762d5 (patch)
tree549c353f66a949282fd8a5e465bc4a02ccf957f4 /pylint
parente36fa7af09835580c84fac4eb79c18dab71a8734 (diff)
downloadpylint-git-5bcdf822c328c4f2878fd4e54490bfee7e1762d5.tar.gz
`in` is considered iterating context for some of the Python 3 porting checkers
Close #2186
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/python3.py5
-rw-r--r--pylint/test/unittest_checker_python3.py1
2 files changed, 6 insertions, 0 deletions
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index 497fafadf..d2bc05897 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -113,6 +113,11 @@ def _in_iterating_context(node):
isinstance(parent.targets[0], (astroid.List, astroid.Tuple))):
if len(parent.targets[0].elts) > 1:
return True
+ # If the call is in a containment check, we consider that to
+ # be an iterating context
+ elif (isinstance(parent, astroid.Compare)
+ and len(parent.ops) == 1 and parent.ops[0][0] == 'in'):
+ return True
return False
diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py
index 20d01d413..f8fc22f48 100644
--- a/pylint/test/unittest_checker_python3.py
+++ b/pylint/test/unittest_checker_python3.py
@@ -206,6 +206,7 @@ class TestPython3Checker(testutils.CheckerTestCase):
'a, b = {}()',
'max({}())',
'min({}())',
+ '3 in {}()',
]
non_iterating_code = [
'x = __({}())',