You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
get_type_hints() always raises on forward references #508
ericvsmith/dataclasses#92 (comment) raised an important question (this existing problem is also mentioned in PEP 563). Currently, get_type_hints will raise a NameError in situations where it might not be the desired behaviour (e.g. if used by a class decorator). For example:
defmodify(cls):
types=get_type_hints(cls)
# do something with 'cls' and 'types'returncls@modifyclassC:
linked: 'C'
It looks like it will be useful to have an option to keep forward references that are currently undefined. For example:
Activity
gvanrossum commentedon Dec 4, 2017
djrochford commentedon Apr 17, 2019
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...
ilevkivskyi commentedon Apr 17, 2019
This is not easy, but not too hard either. I just didn't have time for this, sorry.
djrochford commentedon Apr 17, 2019
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.
The-Compiler commentedon Apr 16, 2021
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
srittau commentedon Nov 4, 2021
Please report this bug to bugs.python.org if it still exists.