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
I ran mypy on a code snippet with two overloads of a function. In those overloads, the arguments are a tuple that starts with the same type for both overloads but is followed by an arbitrary amount of objects of two different types.
Mypy raises an AssertionError when comparing both Unpack objects to check whether the types overlap.
Traceback
$ mypy tmp.py --show-traceback
tmp.py:7: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.11.0+dev.6c24ea66e20166964aa5d42e28fda5b4b69f44b1
Traceback (most recent call last):
File "/home/fblanke/miniforge3/envs/mypy_debug/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/main.py", line 103, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/main.py", line 187, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 193, in build
result = _build(
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 268, in _build
graph = dispatch(sources, manager, stdout)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 2950, in dispatch
process_graph(graph, manager)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 3348, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 3449, in process_stale_scc
graph[id].type_check_first_pass()
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/build.py", line 2314, in type_check_first_pass
self.type_checker().check_first_pass()
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 482, in check_first_pass
self.accept(d)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 590, in accept
stmt.accept(self)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/nodes.py", line 587, in accept
return visitor.visit_overloaded_func_def(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 627, in visit_overloaded_func_def
self._visit_overloaded_func_def(defn)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 657, in _visit_overloaded_func_def
self.check_overlapping_overloads(defn)
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 788, in check_overlapping_overloads
if is_unsafe_overlapping_overload_signatures(sig1, sig2, type_vars):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 7837, in is_unsafe_overlapping_overload_signatures
return is_callable_compatible(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/subtypes.py", line 1561, in is_callable_compatible
return are_parameters_compatible(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/subtypes.py", line 1676, in are_parameters_compatible
if not are_args_compatible(
^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/subtypes.py", line 1832, in are_args_compatible
return is_compat(right.typ, left.typ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/subtypes.py", line 1837, in new_is_compat
return is_compat(right, left)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/checker.py", line 8366, in is_overlapping_types_no_promote_no_uninhabited_no_none
return is_overlapping_types(
^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/meet.py", line 434, in is_overlapping_types
return are_tuples_overlapping(left, right, ignore_promotions=ignore_promotions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/meet.py", line 616, in are_tuples_overlapping
return all(
^^^^
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/meet.py", line 617, in <genexpr>
is_overlapping_types(
File "/home/fblanke/miniforge3/envs/mypy_debug/lib/python3.12/site-packages/mypy/meet.py", line 550, in is_overlapping_types
assert type(left) != type(right), f"{type(left)} vs {type(right)}"
^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: <class 'mypy.types.UnpackType'> vs <class 'mypy.types.UnpackType'>
tmp.py:7: : note: use --pdb to drop into pdb
To Reproduce
I created a small stand-alone snippet that triggers the crash:
Currently, mypy crashes at comparison of two overloads that use
unpacking on unbounded tuple types. This adds an ad hoc fix
by adding the correspond check in the function and instead
compares the two wrapped inner types that are unpacked.
See mypy issue python#17319:
python#17319
Crash Report
I ran mypy on a code snippet with two overloads of a function. In those overloads, the arguments are a tuple that starts with the same type for both overloads but is followed by an arbitrary amount of objects of two different types.
Mypy raises an AssertionError when comparing both Unpack objects to check whether the types overlap.
Traceback
To Reproduce
I created a small stand-alone snippet that triggers the crash:
Your Environment
mypy 1.11.0+dev.6c24ea66e20166964aa5d42e28fda5b4b69f44b1 (compiled: no)
--show-traceback
mypy.ini
(and other config files): ran without a configuration file6.9.2-arch1-1
The text was updated successfully, but these errors were encountered: