-
Notifications
You must be signed in to change notification settings - Fork 115
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
NameError on Enum #402
Comments
Have you tried |
No I didn't, but as is it's ok with |
Mypy doesn't have to look up things at run time. |
That's true, but how do we decide whether typeguard should understand a particular annotation or not? My idea is we check whether mypy understands it, and if yes, than typeguard should too, if possible. I don't think we should expect a user to change their code for typeguard to understand it. |
And if for some reason typeguard can't process some annotation correctly, at least it should not crash, preventing the app from running further. |
Now I have:
|
That should have been: |
That sounds extremely weird, and doesn't follow any guidelines on writing annotations and otherwise referencing variables. Also, it doesn't help:
|
It seems that |
It's not like Typeguard is considering |
Well, that sounds reasonable, isn't it? |
I just have a creeping feeling that I'm adding hacks on top of hacks and it's going to lead to more regressions down the line. But what else can I do? 🤷 |
Yeah, I understand that. :( It seems like the only other thing possible is detecting situations like this and just skipping checking for them. |
By the way, that example works if you add |
I have a failing unit test for this now. |
Yep, but it works very weirdly: $ python3 A.py
OK
$ python3 test.py
OK
OK Why the extra instantiation? |
Does |
You're instantiating |
Oh, my bad. Instantiation is definitely not needed in |
This problem is still actual for The error message is a bit different, though: |
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Typeguard version
4.1.5
Python version
3.10.12
What happened?
How can we reproduce the bug?
test.py
:A.py
:The text was updated successfully, but these errors were encountered: