-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
ClassVar fails when __future__ annotations used in python3.9 #279
Comments
Because Here is an example: from typing import Generic, TypeVar, get_type_hints
from apischema.typing import get_type_hints2
T = TypeVar("T")
class A(Generic[T]):
a: T
U = TypeVar("U")
class B(A[U]):
b: list[U]
# How can I work with this result?
assert get_type_hints(B) == {"a": T, "b": list[U]}
# Better
assert get_type_hints2(B) == {"a": U, "b": list[U]} However, it seems that I have to rewrite my wrapper, because it is using too much internal implementation details. I will try to release a patch for v0.15 and v0.16 this weekend. |
Having written the fix, I remember now why I did a rewrite of |
Thanks for the quick fix, much appreciated! |
Fails with:
With apischema 0.16.4 on python 3.9
I had a quick dig around and it appears that
ForwardRef
added anis_class
argument for python3.9 and fails for ClassVars if this is not passed.I'm happy to submit a PR that adds yet another version check in apischema/typing.py if that's useful, but was curious as why you don't use
get_type_hints()
to get this information?The text was updated successfully, but these errors were encountered: