diff options
| author | Nick Drozd <nicholasdrozd@gmail.com> | 2023-04-12 17:06:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-12 21:06:34 +0000 |
| commit | c1f8ca83f12580e4ca93d46b3c6e590aa6025377 (patch) | |
| tree | 81ca7de8c574a572eb719f3a4bde733174ce6ec4 /astroid/nodes/node_classes.py | |
| parent | 0bfe98ea4bd5407d8b3905dd6b340c4842fb2019 (diff) | |
| download | astroid-git-c1f8ca83f12580e4ca93d46b3c6e590aa6025377.tar.gz | |
Clean up If fields (#2109)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'astroid/nodes/node_classes.py')
| -rw-r--r-- | astroid/nodes/node_classes.py | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index deb8ed54..aca273ca 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -2438,44 +2438,19 @@ class If(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement): _astroid_fields = ("test", "body", "orelse") _multi_line_block_fields = ("body", "orelse") - def __init__( - self, - lineno: int, - col_offset: int, - parent: NodeNG, - *, - end_lineno: int | None, - end_col_offset: int | None, - ) -> None: - self.test: NodeNG - """The condition that the statement tests. - - This attribute gets set in the postinit method. - """ - - self.body: list[NodeNG] = [] - """The contents of the block.""" - - self.orelse: list[NodeNG] = [] - """The contents of the ``else`` block.""" + test: NodeNG + """The condition that the statement tests.""" - self.is_orelse: bool = False - """Whether the if-statement is the orelse-block of another if statement.""" + body: list[NodeNG] + """The contents of the block.""" - super().__init__( - lineno=lineno, - col_offset=col_offset, - end_lineno=end_lineno, - end_col_offset=end_col_offset, - parent=parent, - ) + orelse: list[NodeNG] + """The contents of the ``else`` block.""" def postinit(self, test: NodeNG, body: list[NodeNG], orelse: list[NodeNG]) -> None: self.test = test self.body = body self.orelse = orelse - if isinstance(self.parent, If) and self in self.parent.orelse: - self.is_orelse = True @cached_property def blockstart_tolineno(self): |
