-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
make_class(): Populate the __annotations__ dict #1271
Comments
Solved it in Typed Settings, so fixing this is not super important. The |
Any reason you dumped a diff instead of a PR? 😅 |
It's just a draft for helping you decide whether you like this change or not. If you like it, I will prepare a PR. :-) |
sscherfke
added a commit
that referenced
this issue
May 19, 2024
13 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 13, 2024
* make_class(): Add "__annotations_" to generated class Fixes: #1271 * Fix PR# * Flip --------- Co-authored-by: Hynek Schlawack <hs@ox.cx>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make_class()
currently doesn't touch the__annotations__
dict when it creates a new class.This can become a problem when a class is created dynamically with unresolved types. And when
__annotations__
is empty,resolve_type()
on the generated class will do nothing.Here is a use case: https://gitlab.com/sscherfke/typed-settings/-/issues/54
There's not much required to fix this:
The only problem with this is the unfortunate default of
field(type=None)
, b/c we cannot differentiate between an explicitNone
type an no type. I’m afraid though, that changing the default oftype=
to a sentinel object would be a braking change.The text was updated successfully, but these errors were encountered: