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 the following conditions are met:
A generic class is present.
The generic class refers to a typevar T that is bound to a sequence.
The generic class has a method that attempts to pattern match a method parameter of type T
One of the pattern matching cases is a sequence pattern such as _, _.
This crash is similar to but distinct from this issue: #12448
Traceback
$ mypy mypy_mre.py --show-traceback
mypy_mre.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.14.0+dev.05a9e79068a5830e57264390c9f6bca859e92053
Traceback (most recent call last):
File "~/venv-3.11.6/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/main.py", line 109, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/main.py", line 193, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 194, in build
result = _build(
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 269, in _build
graph = dispatch(sources, manager, stdout)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 2937, in dispatch
process_graph(graph, manager)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 3335, in process_graph
process_stale_scc(graph, scc, manager)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 3436, in process_stale_scc
graph[id].type_check_first_pass()
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/build.py", line 2306, in type_check_first_pass
self.type_checker().check_first_pass()
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 483, in check_first_pass
self.accept(d)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 592, in accept
stmt.accept(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/nodes.py", line 1196, in accept
return visitor.visit_class_def(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 2461, in visit_class_def
self.accept(defn.defs)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 592, in accept
stmt.accept(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/nodes.py", line 1277, in accept
return visitor.visit_block(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 2951, in visit_block
self.accept(s)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 592, in accept
stmt.accept(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/nodes.py", line 827, in accept
return visitor.visit_func_def(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 1046, in visit_func_def
self._visit_func_def(defn)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 1050, in _visit_func_def
self.check_func_item(defn, name=defn.name)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 1084, in check_func_item
self.check_func_def(defn, typ, name, allow_empty)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 1360, in check_func_def
self.accept(item.body)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 592, in accept
stmt.accept(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/nodes.py", line 1277, in accept
return visitor.visit_block(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 2951, in visit_block
self.accept(s)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 592, in accept
stmt.accept(self)
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/nodes.py", line 1661, in accept
return visitor.visit_match_stmt(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 5298, in visit_match_stmt
pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checker.py", line 5298, in <listcomp>
pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checkpattern.py", line 129, in accept
result = o.accept(self)
^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/patterns.py", line 93, in accept
return visitor.visit_sequence_pattern(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checkpattern.py", line 345, in visit_sequence_pattern
new_type = self.construct_sequence_child(current_type, new_inner_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv-3.11.6/lib/python3.11/site-packages/mypy/checkpattern.py", line 766, in construct_sequence_child
assert isinstance(proper_type, Instance)
AssertionError:
mypy_mre.py:7: : note: use --pdb to drop into pdb
Crash Report
mypy crashes when the following conditions are met:
T
that is bound to a sequence.T
_, _
.This crash is similar to but distinct from this issue: #12448
Traceback
To Reproduce
Here is an MRE:
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: