summaryrefslogtreecommitdiff
path: root/pylint/checkers/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/checkers/base.py')
-rw-r--r--pylint/checkers/base.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index e787965..1ae2f53 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -358,8 +358,11 @@ class BasicErrorChecker(_BasicChecker):
@check_messages('yield-outside-function')
def visit_yield(self, node):
- if not isinstance(node.frame(), (astroid.Function, astroid.Lambda)):
- self.add_message('yield-outside-function', node=node)
+ self._check_yield_outside_func(node)
+
+ @check_messages('yield-outside-function')
+ def visit_yieldfrom(self, node):
+ self._check_yield_outside_func(node)
@check_messages('not-in-loop')
def visit_continue(self, node):
@@ -414,6 +417,10 @@ class BasicErrorChecker(_BasicChecker):
args=(infered.name, ),
node=node)
+ def _check_yield_outside_func(self, node):
+ if not isinstance(node.frame(), (astroid.Function, astroid.Lambda)):
+ self.add_message('yield-outside-function', node=node)
+
def _check_else_on_loop(self, node):
"""Check that any loop with an else clause has a break statement."""
if node.orelse and not _loop_exits_early(node):