You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importnot_found_at_compile_time# in my case: the PEP-517 build dependencies did not list all the runtime dependencies to be also present at build/compile timedeftest(x: dict[int, int] |not_found_at_compile_time.A) ->None:
ifisinstance(x, dict):
test= {key: valueforkey, valueinx.items()}
Expected Behavior
mypyc does not crash.
Actual Behavior
mypyc crashes:
$ mypy test.py
Success: no issues found in 1 source file
$ mypyc test.py
Traceback (most recent call last):
File "mypyc/irbuild/builder.py", line 247, in accept
File "mypy/nodes.py", line 2368, in accept
File "mypyc/irbuild/visitor.py", line 314, in visit_dictionary_comprehension
File "mypyc/irbuild/expression.py", line 995, in transform_dictionary_comprehension
File "mypyc/irbuild/for_helpers.py", line 330, in comprehension_helper
File "mypyc/irbuild/for_helpers.py", line 290, in handle_loop
File "mypyc/irbuild/for_helpers.py", line 101, in for_loop_helper
File "mypyc/irbuild/for_helpers.py", line 467, in make_for_loop_generator
File "mypyc/irbuild/builder.py", line 901, in get_dict_item_type
File "mypyc/irbuild/builder.py", line 893, in get_dict_key_type
File "mypyc/irbuild/builder.py", line 888, in get_dict_base_type
test.py:6: AssertionError: Union[builtins.dict[builtins.int, builtins.int], builtins.dict[Any, Any]]
Your Environment
Mypy version used: 1.0.0
Python version used: 3.11.1
The text was updated successfully, but these errors were encountered:
Feel free to close it here if that makes it easier to manage/prioritize the issues.
I think the above example worked with the pervious mypy release.
To be fair, I somehow like the new "behavior": as it ensures that all dependencies are installed at compile time :) I assume, while previous mypyc version did not crash, they probably compiled less ideal code (key and values were probably Any instead of int).
An optimization to make iterating over dict.keys(), dict.values() and
dict.items() faster caused mypyc to crash while compiling a Union of
dictionaries. This commit fixes the optimization helpers to properly
handle unions.
irbuild.Builder.get_dict_base_type() now returns list[Instance] with the
union items. In the common case we don't have a union, a single-element
list is returned. And get_dict_key_type() and get_dict_value_type() will
now build a simplified RUnion as needed.
Fixesmypyc/mypyc#965 and probably #14694.
Bug Report
The following worked with mypy<1.0.
To Reproduce
Expected Behavior
mypyc does not crash.
Actual Behavior
mypyc crashes:
Your Environment
The text was updated successfully, but these errors were encountered: