Skip to content
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

attrs plugin ignores field alias #16586

Closed
kshpytsya opened this issue Nov 29, 2023 · 0 comments · Fixed by #16610
Closed

attrs plugin ignores field alias #16586

kshpytsya opened this issue Nov 29, 2023 · 0 comments · Fixed by #16610
Labels
bug mypy got something wrong topic-attrs

Comments

@kshpytsya
Copy link

$ mypy --version
mypy 1.7.1 (compiled: yes)
$ venv/bin/pip list|grep attrs
attrs      23.1.0
$ cat a.py
import attrs


@attrs.define
class A:
    _x: int = attrs.field(alias="_x")


a = A(_x=1)
a = A(x=1)
 $ venv/bin/python  a.py
Traceback (most recent call last):
  File "/home/uken/src/mypy-attrs-alias.bug/a.py", line 10, in <module>
    a = A(x=1)
        ^^^^^^
TypeError: A.__init__() got an unexpected keyword argument 'x'
$ mypy --python-executable=venv/bin/python  a.py
a.py:9: error: Unexpected keyword argument "_x" for "A"  [call-arg]
Found 1 error in 1 file (checked 1 source file)

See: https://www.attrs.org/en/stable/init.html#private-attributes-and-aliases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-attrs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants