Closed kilroy42 closed 5 months ago
Typeguard relies on the __required_keys__
attribute which still contains notNeeded
in this case. I need a workaround that compiles the list of required keys differently.
To make matters even worse, get_type_hints()
completely erases the NotRequired
annotation.
I have a fix in place, but having some trouble writing a proper test for it.
For future reference, this is a known limitation of NotRequired
/Required
reported previously in https://github.com/python/typing_extensions/issues/55 & https://github.com/python/cpython/issues/97727 and it is unlikely that it will ever be fixed upstream.
Things to check first
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Typeguard version
4.1.5
Python version
3.11 / 3.12
What happened?
The following program should output the dictionary and not raise an Exception.
But the following happens:
BUT if you remove the first line (
from __future__ import annotations
), it works as expected.How can we reproduce the bug?
Run the code once unmodified. Then run the code with the first line removed.