diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2020-06-09 22:02:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-09 22:02:48 +0200 |
| commit | 1cf413ff986cf464202a07df60e7bd54695ed0e0 (patch) | |
| tree | 65ecd70f5d6057047403122e9f01158038f22637 /astroid | |
| parent | ca821aacd3d27b118781de77463238aa58f1f3ca (diff) | |
| download | astroid-git-1cf413ff986cf464202a07df60e7bd54695ed0e0.tar.gz | |
`FunctionDef.is_generator` properly handles `yield` nodes in `If` tests (#799)
Close PyCQA/pylint#3583
Diffstat (limited to 'astroid')
| -rw-r--r-- | astroid/node_classes.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/astroid/node_classes.py b/astroid/node_classes.py index 621dc5f2..8cc8585d 100644 --- a/astroid/node_classes.py +++ b/astroid/node_classes.py @@ -3508,6 +3508,11 @@ class If(mixins.MultiLineBlockMixin, mixins.BlockRangeMixIn, Statement): def has_elif_block(self): return len(self.orelse) == 1 and isinstance(self.orelse[0], If) + def _get_yield_nodes_skip_lambdas(self): + """An If node can contain a Yield node in the test""" + yield from self.test._get_yield_nodes_skip_lambdas() + yield from super()._get_yield_nodes_skip_lambdas() + class IfExp(NodeNG): """Class representing an :class:`ast.IfExp` node. |
