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
typing.get_type_hints fails when passed a class with PEP 695 type parameters and PEP 563 is enabled #114053
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, my now-hidden comment above is incorrect - it does work fine with pre-695 generic classes, I just had a typo in the code. This is only an issue with PEP 695 type parameters in conjunction with PEP 563. |
+1, just ran into this as well. |
I suppose the problem is probably that |
…ts`` (#118009) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…`get_type_hints`` (python#118009) (cherry-picked from commit 1e3e7ce) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
I created a temporary workaround based off the fix by @AlexWaygood if anyone needs a hack around this in the meantime: https://gist.github.com/treykeown/65c45b3da330d2293c7fb9d2a46520ed |
Bug report
Bug description:
This fails with a NameError:
Although
get_type_hints
does not work with imported imported type aliases, this is not imported, so I would expect it to work. Further, the documentation for the function indicates using PEP 563 should /help/, but in this case it actually causes an error.FWIW, removing the PEP 563 import works fine, giving:
Python version:
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
get_type_hints
#118009get_type_hints
(#118009) #118104The text was updated successfully, but these errors were encountered: