summaryrefslogtreecommitdiff
path: root/astroid/nodes/node_classes.py
diff options
context:
space:
mode:
authorNick Drozd <nicholasdrozd@gmail.com>2023-01-30 12:10:34 -0500
committerDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2023-04-07 09:20:23 +0200
commit02a622ad3f798c640c541985af5b85ee0233f5fa (patch)
tree570307df92eb6859e5640c530eef2486b08fecf9 /astroid/nodes/node_classes.py
parent51d8507c6baae6847601e0de7e319d1a5c7f7f5b (diff)
downloadastroid-git-02a622ad3f798c640c541985af5b85ee0233f5fa.tar.gz
Mandatory fields for ExceptHandler
Diffstat (limited to 'astroid/nodes/node_classes.py')
-rw-r--r--astroid/nodes/node_classes.py76
1 files changed, 16 insertions, 60 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py
index 0cecb025..5b83d2cb 100644
--- a/astroid/nodes/node_classes.py
+++ b/astroid/nodes/node_classes.py
@@ -2079,53 +2079,30 @@ class ExceptHandler(
_astroid_fields = ("type", "name", "body")
_multi_line_block_fields = ("body",)
- 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.type: NodeNG | None = None # can be None
- """The types that the block handles.
+ type: NodeNG | None
+ """The types that the block handles."""
- :type: Tuple or NodeNG or None
- """
+ name: AssignName | None
+ """The name that the caught exception is assigned to."""
- self.name: AssignName | None = None # can be None
- """The name that the caught exception is assigned to."""
-
- self.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,
- )
+ body: list[NodeNG]
+ """The contents of the block."""
assigned_stmts: ClassVar[AssignedStmtsCall[ExceptHandler]]
"""Returns the assigned statement (non inferred) according to the assignment type.
See astroid/protocols.py for actual implementation.
"""
+ def postinit(
+ self,
+ type: NodeNG | None, # pylint: disable = redefined-builtin
+ name: AssignName | None,
+ body: list[NodeNG],
+ ) -> None:
+ self.type = type
+ self.name = name
+ self.body = body
+
def get_children(self):
if self.type is not None:
yield self.type
@@ -2135,27 +2112,6 @@ class ExceptHandler(
yield from self.body
- # pylint: disable=redefined-builtin; had to use the same name as builtin ast module.
- def postinit(
- self,
- type: NodeNG | None = None,
- name: AssignName | None = None,
- body: list[NodeNG] | None = None,
- ) -> None:
- """Do some setup after initialisation.
-
- :param type: The types that the block handles.
- :type type: Tuple or NodeNG or None
-
- :param name: The name that the caught exception is assigned to.
-
- :param body:The contents of the block.
- """
- self.type = type
- self.name = name
- if body is not None:
- self.body = body
-
@cached_property
def blockstart_tolineno(self):
"""The line on which the beginning of this block ends.