diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-11-24 13:50:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 13:50:11 +0100 |
commit | 444315963dcfec56d2539f72895ff98c07f2d31d (patch) | |
tree | 3d0ade2e5941cc4e7ede8082eb23473bcd76c561 /astroid/mixins.py | |
parent | 7ed1ee9df2a8f384fe2587dff44aba85ef289cf7 (diff) | |
download | astroid-git-444315963dcfec56d2539f72895ff98c07f2d31d.tar.gz |
Add ``future`` argument to all ``NodeNG.statement()`` calls (#1235)
* Add ``future`` argument to all ``NodeNG.statement()`` calls
* Add typing from ``statement()``
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'astroid/mixins.py')
-rw-r--r-- | astroid/mixins.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/astroid/mixins.py b/astroid/mixins.py index d7c027a1..3241ecea 100644 --- a/astroid/mixins.py +++ b/astroid/mixins.py @@ -16,10 +16,14 @@ """This module contains some mixins for the different nodes. """ import itertools +from typing import TYPE_CHECKING, Optional from astroid import decorators from astroid.exceptions import AttributeInferenceError +if TYPE_CHECKING: + from astroid import nodes + class BlockRangeMixIn: """override block range""" @@ -44,9 +48,9 @@ class BlockRangeMixIn: class FilterStmtsMixin: """Mixin for statement filtering and assignment type""" - def _get_filtered_stmts(self, _, node, _stmts, mystmt): + def _get_filtered_stmts(self, _, node, _stmts, mystmt: Optional["nodes.Statement"]): """method used in _filter_stmts to get statements and trigger break""" - if self.statement() is mystmt: + if self.statement(future=True) is mystmt: # original node's statement is the assignment, only keep # current node (gen exp, list comp) return [node], True @@ -60,11 +64,13 @@ class AssignTypeMixin: def assign_type(self): return self - def _get_filtered_stmts(self, lookup_node, node, _stmts, mystmt): + def _get_filtered_stmts( + self, lookup_node, node, _stmts, mystmt: Optional["nodes.Statement"] + ): """method used in filter_stmts""" if self is mystmt: return _stmts, True - if self.statement() is mystmt: + if self.statement(future=True) is mystmt: # original node's statement is the assignment, only keep # current node (gen exp, list comp) return [node], True |