-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small refactor after 3.12 support #2227
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2705,16 +2705,19 @@ class ParamSpec(_base_nodes.AssignTypeNode): | |
<ParamSpec l.1 at 0x7f23b2e4e198> | ||
""" | ||
|
||
_astroid_fields = ("name",) | ||
|
||
name: AssignName | ||
|
||
def __init__( | ||
self, | ||
lineno: int, | ||
col_offset: int, | ||
parent: NodeNG, | ||
*, | ||
end_lineno: int | None = None, | ||
end_col_offset: int | None = None, | ||
end_lineno: int | None, | ||
end_col_offset: int | None, | ||
) -> None: | ||
self.name: AssignName | None | ||
super().__init__( | ||
lineno=lineno, | ||
col_offset=col_offset, | ||
|
@@ -2723,7 +2726,7 @@ def __init__( | |
parent=parent, | ||
) | ||
|
||
def postinit(self, *, name: AssignName | None) -> None: | ||
def postinit(self, *, name: AssignName) -> None: | ||
self.name = name | ||
|
||
|
||
|
@@ -3350,20 +3353,21 @@ class TypeAlias(_base_nodes.AssignTypeNode): | |
<TypeAlias l.1 at 0x7f23b2e4e198> | ||
""" | ||
|
||
_astroid_fields = ("type_params", "value") | ||
_astroid_fields = ("name", "type_params", "value") | ||
|
||
name: AssignName | ||
type_params: list[TypeVar | ParamSpec | TypeVarTuple] | ||
value: NodeNG | ||
Comment on lines
+3358
to
+3360
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not totally sure why we're adopting this pattern instead of using the constructor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like it as well, but I do think we should at least try and keep one style so that we can then refactor it to a desired style all at once? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries. Sometimes it seems like we prefer not to mass-replace, but not a big deal, let's keep moving. π |
||
|
||
def __init__( | ||
self, | ||
lineno: int, | ||
col_offset: int, | ||
parent: NodeNG, | ||
*, | ||
end_lineno: int | None = None, | ||
end_col_offset: int | None = None, | ||
end_lineno: int | None, | ||
end_col_offset: int | None, | ||
) -> None: | ||
self.name: AssignName | None | ||
self.type_params: list[TypeVar, ParamSpec, TypeVarTuple] | ||
self.value: NodeNG | ||
super().__init__( | ||
lineno=lineno, | ||
col_offset=col_offset, | ||
|
@@ -3375,8 +3379,8 @@ def __init__( | |
def postinit( | ||
self, | ||
*, | ||
name: AssignName | None, | ||
type_params: list[TypeVar, ParamSpec, TypeVarTuple], | ||
name: AssignName, | ||
type_params: list[TypeVar | ParamSpec | TypeVarTuple], | ||
Comment on lines
-3378
to
+3383
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch, thank you, I was just working too quickly. |
||
value: NodeNG, | ||
) -> None: | ||
self.name = name | ||
|
@@ -3393,19 +3397,20 @@ class TypeVar(_base_nodes.AssignTypeNode): | |
<TypeVar l.1 at 0x7f23b2e4e198> | ||
""" | ||
|
||
_astroid_fields = ("bound",) | ||
_astroid_fields = ("name", "bound") | ||
|
||
name: AssignName | ||
bound: NodeNG | None | ||
|
||
def __init__( | ||
self, | ||
lineno: int, | ||
col_offset: int, | ||
parent: NodeNG, | ||
*, | ||
end_lineno: int | None = None, | ||
end_col_offset: int | None = None, | ||
end_lineno: int | None, | ||
end_col_offset: int | None, | ||
) -> None: | ||
self.name: AssignName | None | ||
self.bound: NodeNG | None | ||
super().__init__( | ||
lineno=lineno, | ||
col_offset=col_offset, | ||
|
@@ -3414,7 +3419,7 @@ def __init__( | |
parent=parent, | ||
) | ||
|
||
def postinit(self, *, name: AssignName | None, bound: NodeNG | None) -> None: | ||
def postinit(self, *, name: AssignName, bound: NodeNG | None) -> None: | ||
self.name = name | ||
self.bound = bound | ||
|
||
|
@@ -3428,16 +3433,19 @@ class TypeVarTuple(_base_nodes.AssignTypeNode): | |
<TypeVarTuple l.1 at 0x7f23b2e4e198> | ||
""" | ||
|
||
_astroid_fields = ("name",) | ||
|
||
name: AssignName | ||
|
||
def __init__( | ||
self, | ||
lineno: int, | ||
col_offset: int, | ||
parent: NodeNG, | ||
*, | ||
end_lineno: int | None = None, | ||
end_col_offset: int | None = None, | ||
end_lineno: int | None, | ||
end_col_offset: int | None, | ||
) -> None: | ||
self.name: AssignName | None | ||
super().__init__( | ||
lineno=lineno, | ||
col_offset=col_offset, | ||
|
@@ -3446,7 +3454,7 @@ def __init__( | |
parent=parent, | ||
) | ||
|
||
def postinit(self, *, name: AssignName | None) -> None: | ||
def postinit(self, *, name: AssignName) -> None: | ||
self.name = name | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I missed these because I went back and forth on whether this should be a
str
or anAssignName
until I saw the references for the similar issue withMatchStar
and friends pointing to python/cpython#88160.