-
Notifications
You must be signed in to change notification settings - Fork 258
get_type_hints() always raises on forward references #508
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
If it's easy to fix, go ahead!
|
I take it this was not easy to fix? I, for one, would be very glad to see this fixed, but I gather that's unlikely to happen soon... |
This is not easy, but not too hard either. I just didn't have time for this, sorry. |
Oh, no need to apologise! I commented only in the hope of bumping this slightly higher the priority list, but I'll survive, and life is short. |
Is there any chance to get this fixed in the near future? |
You can temporarily fix this issue by passing a dict as parameter with the needed classes to the function. |
A somewhat related Python bug I've opened about this a couple of weeks ago (before finding this issue): Issue 43463: typing.get_type_hints with TYPE_CHECKING imports / getting hints for single argument - Python tracker |
Please report this bug to bugs.python.org if it still exists. |
ericvsmith/dataclasses#92 (comment) raised an important question (this existing problem is also mentioned in PEP 563). Currently,
get_type_hints
will raise aNameError
in situations where it might not be the desired behaviour (e.g. if used by a class decorator). For example:It looks like it will be useful to have an option to keep forward references that are currently undefined. For example:
The text was updated successfully, but these errors were encountered: