Skip to content

Commit 9f5b43d

Browse files
committed
Mandatory fields for Assign
1 parent ce07459 commit 9f5b43d

File tree

1 file changed

+11
-48
lines changed

1 file changed

+11
-48
lines changed

astroid/nodes/node_classes.py

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,62 +1202,25 @@ class Assign(_base_nodes.AssignTypeNode, _base_nodes.Statement):
12021202
<Assign l.1 at 0x7effe1db8550>
12031203
"""
12041204

1205-
_astroid_fields = ("targets", "value")
1206-
_other_other_fields = ("type_annotation",)
1207-
1208-
def __init__(
1209-
self,
1210-
lineno: int | None = None,
1211-
col_offset: int | None = None,
1212-
parent: NodeNG | None = None,
1213-
*,
1214-
end_lineno: int | None = None,
1215-
end_col_offset: int | None = None,
1216-
) -> None:
1217-
"""
1218-
:param lineno: The line that this node appears on in the source code.
1219-
1220-
:param col_offset: The column that this node appears on in the
1221-
source code.
1222-
1223-
:param parent: The parent node in the syntax tree.
1224-
1225-
:param end_lineno: The last line this node appears on in the source code.
1226-
1227-
:param end_col_offset: The end column this node appears on in the
1228-
source code. Note: This is after the last symbol.
1229-
"""
1230-
self.targets: list[NodeNG] = []
1231-
"""What is being assigned to."""
1205+
targets: list[NodeNG]
1206+
"""What is being assigned to."""
12321207

1233-
self.value: NodeNG | None = None
1234-
"""The value being assigned to the variables."""
1208+
value: NodeNG
1209+
"""The value being assigned to the variables."""
12351210

1236-
self.type_annotation: NodeNG | None = None # can be None
1237-
"""If present, this will contain the type annotation passed by a type comment"""
1211+
type_annotation: NodeNG | None
1212+
"""If present, this will contain the type annotation passed by a type comment"""
12381213

1239-
super().__init__(
1240-
lineno=lineno,
1241-
col_offset=col_offset,
1242-
end_lineno=end_lineno,
1243-
end_col_offset=end_col_offset,
1244-
parent=parent,
1245-
)
1214+
_astroid_fields = ("targets", "value")
1215+
_other_other_fields = ("type_annotation",)
12461216

12471217
def postinit(
12481218
self,
1249-
targets: list[NodeNG] | None = None,
1250-
value: NodeNG | None = None,
1219+
targets: list[NodeNG],
1220+
value: NodeNG,
12511221
type_annotation: NodeNG | None = None,
12521222
) -> None:
1253-
"""Do some setup after initialisation.
1254-
1255-
:param targets: What is being assigned to.
1256-
:param value: The value being assigned to the variables.
1257-
:param type_annotation:
1258-
"""
1259-
if targets is not None:
1260-
self.targets = targets
1223+
self.targets = targets
12611224
self.value = value
12621225
self.type_annotation = type_annotation
12631226

0 commit comments

Comments
 (0)