-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Possible regression with attrs.asdict
related to type guarding?
#1185
Comments
Looks like we have a regression but the type hints are correct. I think Mypy isn't clever enough to figure out that |
Ah, of course it's RTFM 🤣.
I guess it's just a regression in the sense that "incorrect code that happened to previously work no longer does". IMO that's less-bad than alternatives. For the record, mypy is happy in both attrs versions when using (Also, I noticed that the example code in the OP was missing a |
|
So uh, can this be closed? |
I'm fine with it, but given @Tinche's comment:
I'll let them have the final say. |
Tin, close if OK, otherwise pls expound next actions |
I don't think we can do anything here, this seems like a Mypy limitation. We could start a discussion in the typing section of DPO. Closing this for now. |
Possibly related issues:
AttrsInstance
protocol is incompatible with type checkers other than mypy #996Related PRs:
TypeGuard
forhas
in Python 3.10 and above #997Summary
It looks like there's a regression with types guards and
asdict
from 21.4.0 to 23.1.0, and that they TypeGuard onattrs.has
should beOr
attrs.asdict
should acceptinst: Type[AttrsInstance]
Steps to Reproduce:
In 21.4.0, this worked:
In 23.1.0, that same file fails mypy:
Other Info
The text was updated successfully, but these errors were encountered: