-
-
Notifications
You must be signed in to change notification settings - Fork 32k
PEP 649: class __annotate__ is shadowed by compiler-generated one #133037
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
Comments
See related #122285 |
This behavior is pretty inconsistent for other attributes set in the class namespace:
Still, it's probably nicer to make this work the way this issue asks for. This can be fixed with the approach in #131550 if we do the same thing in class namespaces as we already do there for modules (assign |
This was actually already fixed by #132345, because now the compiler-generated (You'll still get your name overwritten if you use the name |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
I'm playing around with PEP 649, PEP 749 annotations and I found this surprising behaviour:
I'm not yet sure why I would write code with annotations and then also write an explicit
__annotate__
, but I would expect the explicit method to prevail over the compiler-generated one. If I explicitly setC.__annotate__ = some_func
afterwards it works as I would expect.Calling
dis
on the provided example shows both__annotate__
s getting compiled, and one overwriting the other in the class.Related to #119180.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: