diff options
author | Nick Drozd <nicholasdrozd@gmail.com> | 2023-04-04 09:31:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 13:31:09 +0000 |
commit | c1ae270bb990b00d681e677e6be31a2b5ce3c2e4 (patch) | |
tree | 7880835d9ee3236164fd3473774f13daa56ebfcc /astroid | |
parent | b4bb2d98a14558310f14778e1591e45193d39bc7 (diff) | |
download | astroid-git-c1ae270bb990b00d681e677e6be31a2b5ce3c2e4.tar.gz |
Mandatory fields for While (#2095)
Diffstat (limited to 'astroid')
-rw-r--r-- | astroid/nodes/node_classes.py | 62 |
1 files changed, 11 insertions, 51 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index eebeddff..aeed360c 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -3863,64 +3863,24 @@ class While(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement): _astroid_fields = ("test", "body", "orelse") _multi_line_block_fields = ("body", "orelse") - def __init__( - self, - lineno: int | None = None, - col_offset: int | None = None, - parent: NodeNG | None = None, - *, - end_lineno: int | None = None, - end_col_offset: int | None = None, - ) -> None: - """ - :param lineno: The line that this node appears on in the source code. - - :param col_offset: The column that this node appears on in the - source code. - - :param parent: The parent node in the syntax tree. - - :param end_lineno: The last line this node appears on in the source code. - - :param end_col_offset: The end column this node appears on in the - source code. Note: This is after the last symbol. - """ - self.test: NodeNG | None = None - """The condition that the loop tests.""" - - self.body: list[NodeNG] = [] - """The contents of the loop.""" + test: NodeNG + """The condition that the loop tests.""" - self.orelse: list[NodeNG] = [] - """The contents of the ``else`` block.""" + body: list[NodeNG] + """The contents of the loop.""" - 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 | None = None, - body: list[NodeNG] | None = None, - orelse: list[NodeNG] | None = None, + test: NodeNG, + body: list[NodeNG], + orelse: list[NodeNG], ) -> None: - """Do some setup after initialisation. - - :param test: The condition that the loop tests. - - :param body: The contents of the loop. - - :param orelse: The contents of the ``else`` block. - """ self.test = test - if body is not None: - self.body = body - if orelse is not None: - self.orelse = orelse + self.body = body + self.orelse = orelse @cached_property def blockstart_tolineno(self): |