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
Two simple programs trigger similar crashes. They both define & use a TypeVar within the body of a class, so that may be the common issue. First program:
a.py:10: 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: 0.950+dev.7ee84c71e851ce373d1824ecc09332caa373148c
a.py:10: : note: use --pdb to drop into pdb
Traceback (most recent call last):
File "/tmp/venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/tmp/venv/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
main(None, sys.stdout, sys.stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/main.py", line 96, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/main.py", line 173, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 180, in build
result = _build(
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 256, in _build
graph = dispatch(sources, manager, stdout)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 2727, in dispatch
process_graph(graph, manager)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 3071, in process_graph
process_stale_scc(graph, scc, manager)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 3169, in process_stale_scc
graph[id].type_check_first_pass()
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 2186, in type_check_first_pass
self.type_checker().check_first_pass()
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 318, in check_first_pass
self.accept(d)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 424, in accept
stmt.accept(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/nodes.py", line 1152, in accept
return visitor.visit_assignment_stmt(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 2193, in visit_assignment_stmt
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 2354, in check_assignment
rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, context=rvalue,
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 3281, in check_simple_assignment
self.check_subtype(rvalue_type, lvalue_type, context, msg,
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 5214, in check_subtype
if is_subtype(subtype, supertype):
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 94, in is_subtype
return _is_subtype(left, right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 151, in _is_subtype
return left.accept(SubtypeVisitor(orig_right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/types.py", line 1328, in accept
return visitor.visit_callable_type(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 354, in visit_callable_type
return self._is_subtype(left.fallback, right)
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 205, in _is_subtype
return is_subtype(left, right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 94, in is_subtype
return _is_subtype(left, right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 151, in _is_subtype
return left.accept(SubtypeVisitor(orig_right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/types.py", line 1065, in accept
return visitor.visit_instance(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 286, in visit_instance
if right.type.is_protocol and is_protocol_implementation(left, right):
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 588, in is_protocol_implementation
assert supertype is not None
AssertionError:
Second program crashes like this (almost the same, except frames of the first crash -8:-4 are absent in this stack:
b.py:11: 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: 0.950+dev.7ee84c71e851ce373d1824ecc09332caa373148c
b.py:11: : note: use --pdb to drop into pdb
Traceback (most recent call last):
File "/tmp/venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/tmp/venv/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
main(None, sys.stdout, sys.stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/main.py", line 96, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/main.py", line 173, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 180, in build
result = _build(
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 256, in _build
graph = dispatch(sources, manager, stdout)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 2727, in dispatch
process_graph(graph, manager)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 3071, in process_graph
process_stale_scc(graph, scc, manager)
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 3169, in process_stale_scc
graph[id].type_check_first_pass()
File "/tmp/venv/lib/python3.10/site-packages/mypy/build.py", line 2186, in type_check_first_pass
self.type_checker().check_first_pass()
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 318, in check_first_pass
self.accept(d)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 424, in accept
stmt.accept(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/nodes.py", line 1152, in accept
return visitor.visit_assignment_stmt(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 2193, in visit_assignment_stmt
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 2354, in check_assignment
rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, context=rvalue,
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 3281, in check_simple_assignment
self.check_subtype(rvalue_type, lvalue_type, context, msg,
File "/tmp/venv/lib/python3.10/site-packages/mypy/checker.py", line 5214, in check_subtype
if is_subtype(subtype, supertype):
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 94, in is_subtype
return _is_subtype(left, right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 151, in _is_subtype
return left.accept(SubtypeVisitor(orig_right,
File "/tmp/venv/lib/python3.10/site-packages/mypy/types.py", line 1065, in accept
return visitor.visit_instance(self)
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 286, in visit_instance
if right.type.is_protocol and is_protocol_implementation(left, right):
File "/tmp/venv/lib/python3.10/site-packages/mypy/subtypes.py", line 588, in is_protocol_implementation
assert supertype is not None
AssertionError:
Your Environment
Mypy version used: Github master 0.950+dev.7ee84c71e851ce373d1824ecc09332caa373148c
Fixes#6801Fixes#10577Fixes#12642Fixes#12337Fixes#10639Fixes#13390
All these crashes are in a sense duplicates of each other. Fix is trivial, except I decided to ban type aliases in protocol bodies. Already in the examples in issues, I have found two cases where people wrote `foo = list[str]`, where they clearly wanted `foo: list[str]`. This can cause hard to spot false negatives.
Crash Report
Two simple programs trigger similar crashes. They both define & use a TypeVar within the body of a class, so that may be the common issue. First program:
Second program:
Traceback
First program:
Second program crashes like this (almost the same, except frames of the first crash -8:-4 are absent in this stack:
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: