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
MyPy crashes when using type var tuple with multiple generic args in overload
Traceback
$ mypy tmp.py --show-traceback
tmp.py:34: 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.fb31409b392c5533b25173705d62ed385ee39cfb
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/main.py", line 100, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/main.py", line 182, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 192, in build
result = _build(
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 266, in _build
graph = dispatch(sources, manager, stdout)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 2946, in dispatch
process_graph(graph, manager)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 3344, in process_graph
process_stale_scc(graph, scc, manager)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 3445, in process_stale_scc
graph[id].type_check_first_pass()
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/build.py", line 2310, in type_check_first_pass
self.type_checker().check_first_pass()
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checker.py", line 481, in check_first_pass
self.accept(d)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/nodes.py", line 1310, in accept
return visitor.visit_assignment_stmt(self)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checker.py", line 2850, in visit_assignment_stmt
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checker.py", line 3027, in check_assignment
rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, context=rvalue)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checker.py", line 4184, in check_simple_assignment
rvalue_type = self.expr_checker.accept(
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 5760, in accept
typ = node.accept(self)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/nodes.py", line 1966, in accept
return visitor.visit_index_expr(self)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 4257, in visit_index_expr
result = self.visit_index_expr_helper(e)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 4271, in visit_index_expr_helper
return self.accept(e.analyzed)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 5760, in accept
typ = node.accept(self)
^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/nodes.py", line 2644, in accept
return visitor.visit_type_alias_expr(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 4706, in visit_type_alias_expr
return self.alias_type_in_runtime_context(alias.node, ctx=alias, alias_definition=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 4749, in alias_type_in_runtime_context
return self.apply_type_arguments_to_callable(tp, item.args, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 4859, in apply_type_arguments_to_callable
self.apply_generic_arguments(it, self.split_for_callable(it, args, ctx), ctx)
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/checkexpr.py", line 3205, in apply_generic_arguments
return applytype.apply_generic_arguments(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/egg-smol-python/lib/python3.12/site-packages/mypy/applytype.py", line 97, in apply_generic_arguments
assert min_arg_count <= len(orig_types) <= len(tvars)
AssertionError:
tmp.py:34: : note: use --pdb to drop into pdb
To Reproduce
(I have commented out some lines which are unnecessary to reproduce the crash).
Create a tmp.py and run mypy tmp.py:
Fixes#17212
Note I removed the problematic asset after all. It is hard to maintain
it, since this function may be called from both explicit application,
and from type inference code paths. And these two cases may have
different min/max type argument count (see tests and comments for
examples).
Crash Report
MyPy crashes when using type var tuple with multiple generic args in overload
Traceback
To Reproduce
(I have commented out some lines which are unnecessary to reproduce the crash).
Create a
tmp.py
and runmypy tmp.py
:Your Environment
Mypy config from pyproject.toml:
Mypy version (also fails on most recent released version):
The text was updated successfully, but these errors were encountered: