-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 for TypedDict with non-literal keys #15557
Comments
I can reproduce this, but importantly, this doesn't crash the first time you run mypy -- only the second time you run mypy. (This indicates that it's probably something to do with mypy's cache.) |
Just noticed that in my original code I get different traceback from the MCVE above:
|
Here's the traceback I get using mypy >mypy main.py --show-traceback
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\alexw\coding\mypy\venv\Scripts\mypy.exe\__main__.py", line 7, in <module>
File "C:\Users\alexw\coding\mypy\mypy\__main__.py", line 15, in console_entry
main()
File "C:\Users\alexw\coding\mypy\mypy\main.py", line 95, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\main.py", line 174, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 194, in build
result = _build(
^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 267, in _build
graph = dispatch(sources, manager, stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 2926, in dispatch
process_graph(graph, manager)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 3317, in process_graph
process_fresh_modules(graph, prev_scc, manager)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 3398, in process_fresh_modules
graph[id].fix_cross_refs()
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 2113, in fix_cross_refs
fixup_module(self.tree, self.manager.modules, self.options.use_fine_grained_cache)
File "C:\Users\alexw\coding\mypy\mypy\fixup.py", line 53, in fixup_module
node_fixer.visit_symbol_table(tree.names, tree.fullname)
File "C:\Users\alexw\coding\mypy\mypy\fixup.py", line 126, in visit_symbol_table
assert stnode.node is not None, (table_fullname + "." + key, cross_ref)
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ('counts.Counts', 'counts.TypedDict') |
Fixes #15557 FWIW I simply copy the logic for handling malformed definitions from named tuples, that seems to be much more robust.
Crash Report
Creating a
TypedDict
with non-literal keys givesTypedDict() expects a dictionary literal as the second argument
. Attempting to ignore this with# type: ignore
causes anAssertionError
if (and only if):TypedDict
definition.mypy_cache
existsTraceback
To Reproduce
Your Environment
The text was updated successfully, but these errors were encountered: