8000 Fix mishandling of typing.Self in attrs generated inits by davfsa · Pull Request #14689 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix mishandling of typing.Self in attrs generated inits #14689

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Merge branch 'master' into bugfix/14685-attrs-self-handling
  • Loading branch information
davfsa committed Feb 15, 2023
commit c40674ba973e03610f25869159a2cc1dde47ba9b
1 change: 1 addition & 0 deletions mypy/plugins/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing_extensions import Final, Literal

import mypy.plugin # To avoid circular imports.
from mypy.errorcodes import LITERAL_REQ
from mypy.expandtype import expand_self_type
from mypy.exprtotype import TypeTranslationError, expr_to_unanalyzed_type
from mypy.nodes import (
Expand Down
6 changes: 5 additions & 1 deletion mypy/plugins/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing_extensions import Final

from mypy import errorcodes, message_registry
from mypy.expandtype import expand_self_type
from mypy.nodes import (
ARG_NAMED,
Expand Down Expand Up @@ -113,7 +114,10 @@ def to_argument(self, current_info: TypeInfo) -> Argument:
)

def to_var(self, current_info: TypeInfo) -> Var:
return Var(self.name, expand_self_type(self.type, self.info, fill_typevars(current_info)))
return Var(
self.alias or self.name,
expand_self_type(self.type, self.info, fill_typevars(current_info)),
)

def serialize(self) -> JsonDict:
assert self.type
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0