summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pylint/checkers/refactoring.py4
-rw-r--r--pylint/test/functional/stop_iteration_inside_generator.py11
2 files changed, 15 insertions, 0 deletions
diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py
index e4883bccd..30f50cdd9 100644
--- a/pylint/checkers/refactoring.py
+++ b/pylint/checkers/refactoring.py
@@ -479,6 +479,10 @@ class RefactoringChecker(checkers.BaseTokenChecker):
return inferred.qname() in KNOWN_INFINITE_ITERATORS
return False
+ if isinstance(node.func, astroid.Attribute):
+ # A next() method, which is now what we want.
+ return
+
inferred = utils.safe_infer(node.func)
if getattr(inferred, 'name', '') == 'next':
frame = node.frame()
diff --git a/pylint/test/functional/stop_iteration_inside_generator.py b/pylint/test/functional/stop_iteration_inside_generator.py
index b08fd221f..d8b74d4c1 100644
--- a/pylint/test/functional/stop_iteration_inside_generator.py
+++ b/pylint/test/functional/stop_iteration_inside_generator.py
@@ -107,3 +107,14 @@ def generator_using_next():
counter = count()
number = next(counter)
yield number * 2
+
+
+# pylint: disable=no-self-use,too-few-public-methods
+class SomeClassWithNext:
+ def next(self):
+ return iter([1, 2, 3])
+ def some_gen(self):
+ for value in self.next():
+ yield value
+
+SomeClassWithNext().some_gen()