-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
builtins: remove object.__annotations__
#14000
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
base: main
Are you sure you want to change the base?
Conversation
Not all objects have annotations, so I think this shouldn't exist. We already have `__annotations__` attributes explicitly set on the objects that do have them (e.g., functions, classes, and modules).
This comment has been minimized.
This comment has been minimized.
This seems promising, we'll just have to add |
The openlibrary change is a true positive, at least on 3.14 where accessing Not sure about the steam.py one; it seems to be using annotations in an odd way. cc @Gobot1234 The other three should go away with the changes I'm about to push. |
In steam.py I'm using it for data parsing I don't think my use case is crazy out of the ordinary but I can stomach adding |
You might need to use |
CI breakage seems due to a release of click 20 minutes ago https://pypi.org/project/click/8.2.0/ |
Diff from mypy_primer, showing the effect of this PR on open source code: steam.py (https://github.com/Gobot1234/steam.py)
- steam/protobufs/struct_messages.py:24: error: Incompatible types in assignment (expression has type "tuple[()]", variable has type "dict[str, Any]") [assignment]
+ steam/protobufs/struct_messages.py:22: error: "StructMessage" has no attribute "__annotations__" [attr-defined]
+ steam/protobufs/struct_messages.py:29: error: "StructMessage" has no attribute "__annotations__" [attr-defined]
- steam/ext/csgo/backpack.py:291: error: Definition of "SLOTS" in base class "DescriptionMixin" is incompatible with definition in base class "BaseItem" [misc]
openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/plugins/upstream/table_of_contents.py: note: In member "extra_fields" of class "TocEntry":
+ openlibrary/plugins/upstream/table_of_contents.py:85: error: "TocEntry" has no attribute "__annotations__" [attr-defined]
+ openlibrary/plugins/upstream/table_of_contents.py: note: In member "is_empty" of class "TocEntry":
+ openlibrary/plugins/upstream/table_of_contents.py:174: error: "TocEntry" has no attribute "__annotations__" [attr-defined]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/third_party/pydantic.py:53: error: "_Wrapped[[VarArg(Any), KwArg(Any)], Any, [VarArg(Any), KwArg(Any)], Any]" has no attribute "__annotations__" [attr-defined]
zulip (https://github.com/zulip/zulip)
+ corporate/lib/decorator.py:144: error: "_Wrapped[[HttpRequest, RemoteRealmBillingSession, **ParamT], HttpResponse, [HttpRequest, **ParamT], HttpResponse]" has no attribute "__annotations__" [attr-defined]
+ corporate/lib/decorator.py:231: error: "_Wrapped[[HttpRequest, RemoteServerBillingSession, **ParamT], HttpResponse, [HttpRequest, **ParamT], HttpResponse]" has no attribute "__annotations__" [attr-defined]
|
Not all objects have annotations, so I think this shouldn't exist.
We already have
__annotations__
attributes explicitly set on theobjects that do have them (e.g., functions, classes, and modules).
Not sure what the fallout of this is going to be; it might not be worth changing.