summaryrefslogtreecommitdiff
path: root/pylint/checkers
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-25 17:49:23 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-25 17:49:23 +0300
commit04f1ffd196a579e9af4acc277d49aff4f33be9f1 (patch)
tree25bd31b48c63f14c6e172d75a68ad8b83db4fc37 /pylint/checkers
parenta0c8e5cfb2834040f49deaef3dea2f52e46f067b (diff)
downloadpylint-04f1ffd196a579e9af4acc277d49aff4f33be9f1.tar.gz
yield-outside-func is also emitted for `yield from`.
Diffstat (limited to 'pylint/checkers')
-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):