summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorNick Drozd <nicholasdrozd@gmail.com>2023-04-03 14:02:22 -0400
committerGitHub <noreply@github.com>2023-04-03 20:02:22 +0200
commitc4d14363d1c271a41fa3203eb9ab0ede33e9ab41 (patch)
treeb251d10cfb2c0131f3f244e34af1f88124b2f73c /astroid
parentec1540d7905ec8f5e9383d928a6bfd89860b94a3 (diff)
downloadastroid-git-c4d14363d1c271a41fa3203eb9ab0ede33e9ab41.tar.gz
Mandatory fields for Assign (#2061)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'astroid')
-rw-r--r--astroid/nodes/node_classes.py61
1 files changed, 12 insertions, 49 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py
index 2d0400ff..f6250542 100644
--- a/astroid/nodes/node_classes.py
+++ b/astroid/nodes/node_classes.py
@@ -1170,62 +1170,25 @@ class Assign(_base_nodes.AssignTypeNode, _base_nodes.Statement):
<Assign l.1 at 0x7effe1db8550>
"""
- _astroid_fields = ("targets", "value")
- _other_other_fields = ("type_annotation",)
-
- 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.targets: list[NodeNG] = []
- """What is being assigned to."""
+ targets: list[NodeNG]
+ """What is being assigned to."""
- self.value: NodeNG | None = None
- """The value being assigned to the variables."""
+ value: NodeNG
+ """The value being assigned to the variables."""
- self.type_annotation: NodeNG | None = None # can be None
- """If present, this will contain the type annotation passed by a type comment"""
+ type_annotation: NodeNG | None
+ """If present, this will contain the type annotation passed by a type comment"""
- super().__init__(
- lineno=lineno,
- col_offset=col_offset,
- end_lineno=end_lineno,
- end_col_offset=end_col_offset,
- parent=parent,
- )
+ _astroid_fields = ("targets", "value")
+ _other_other_fields = ("type_annotation",)
def postinit(
self,
- targets: list[NodeNG] | None = None,
- value: NodeNG | None = None,
- type_annotation: NodeNG | None = None,
+ targets: list[NodeNG],
+ value: NodeNG,
+ type_annotation: NodeNG | None,
) -> None:
- """Do some setup after initialisation.
-
- :param targets: What is being assigned to.
- :param value: The value being assigned to the variables.
- :param type_annotation:
- """
- if targets is not None:
- self.targets = targets
+ self.targets = targets
self.value = value
self.type_annotation = type_annotation