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

(🐞) Crash with TypedDict defined in method (cache moment) #16336

Closed
KotlinIsland opened this issue Oct 27, 2023 · 0 comments · Fixed by #16364
Closed

(🐞) Crash with TypedDict defined in method (cache moment) #16336

KotlinIsland opened this issue Oct 27, 2023 · 0 comments · Fixed by #16364

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Oct 27, 2023

from typing import TypedDict

class C:
    def f(self) -> None:
        class D(TypedDict): ...
        self.d: D
> rm -rf .mypy_cache; mypy test.py; mypy -c "import test"
Traceback (most recent call last):
  File "/home/user/projects/test-python/.venv/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/home/user/projects/test-python/.venv/lib/python3.8/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 99, in main
  File "mypy/main.py", line 178, in run_build
  File "mypy/build.py", line 189, in build
  File "mypy/build.py", line 262, in _build
  File "mypy/build.py", line 2938, in dispatch
  File "mypy/build.py", line 3329, in process_graph
  File "mypy/build.py", line 3410, in process_fresh_modules
  File "mypy/build.py", line 2108, in fix_cross_refs
  File "mypy/fixup.py", line 52, in fixup_module
  File "mypy/fixup.py", line 135, in visit_symbol_table
  File "mypy/fixup.py", line 72, in visit_type_info
  File "mypy/fixup.py", line 137, in visit_symbol_table
  File "mypy/nodes.py", line 1040, in accept
  File "mypy/fixup.py", line 193, in visit_var
  File "mypy/types.py", line 398, in accept
  File "mypy/fixup.py", line 230, in visit_type_alias_type
  File "mypy/fixup.py", line 366, in lookup_fully_qualified_alias
  File "mypy/lookup.py", line 49, in lookup_fully_qualified
AssertionError: Cannot find component 'D' for 'test.C.D'

mypy 1.6.1

JukkaL pushed a commit that referenced this issue Oct 30, 2023
Fixes #16336

All the story with `@`-names is a mess. FWIW I just copied the logic
from named tuples, where it works. So although it is a mess, it will be
now be a consistent mess, with full parity between `NamedTuple` and
`TypedDict`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants