Skip to content
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

Inner classes are not recognized in annotations #482

Closed
2 tasks done
jolaf opened this issue Sep 7, 2024 · 1 comment
Closed
2 tasks done

Inner classes are not recognized in annotations #482

jolaf opened this issue Sep 7, 2024 · 1 comment
Labels

Comments

@jolaf
Copy link
Contributor

jolaf commented Sep 7, 2024

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.3.0

Python version

3.12.3

What happened?

Traceback (most recent call last):
  File "/.../test.py", line 3, in <module>
    import A
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "/home/.../.local/lib/python3.12/site-packages/typeguard/_importhook.py", line 98, in exec_module
    super().exec_module(module)
  File "/.../A.py", line 10, in <module>
    A()
  File "/.../A.py", line 7, in __init__
    def __init__(self, e: E = E.X) -> None:
                          ^
NameError: name 'E' is not defined. Did you mean: 'self.E'?

How can we reproduce the bug?

test.py:

from typeguard import install_import_hook
with install_import_hook(('A',)):
    import A

A.py:

from enum import Enum

class A:
    class E(Enum):
        X = 1

    def __init__(self, e: E = E.X) -> None:
        print("OK")

A()
$ python3 A.py
OK

$ python3 test.py
<crash>
@jolaf jolaf added the bug label Sep 7, 2024
@jolaf jolaf closed this as completed Sep 7, 2024
@jolaf
Copy link
Contributor Author

jolaf commented Sep 7, 2024

Sorry, duplicate of #402.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant