(In this case, I meant to do foo: Callable[..., int].)
Here's the traceback:
test.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/
issues version: 0.630+dev-1222c9637b673bcca6218a943cd4b88b8749b0ad
Traceback (most recent call last):
File "C:\Python3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Michael\Dropbox\mypy\mypy\__main__.py", line 11, in <module>
main(None)
File "C:\Users\Michael\Dropbox\mypy\mypy\main.py", line 91, in main
res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa
File "C:\Users\Michael\Dropbox\mypy\mypy\main.py", line 148, in type_check_only
fscache=fscache)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 177, in build
flush_errors, fscache)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 350, in _build
graph = dispatch(sources, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2572, in dispatch
process_graph(graph, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2866, in process_graph
process_stale_scc(graph, scc, manager)
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2989, in process_stale_scc
graph[id].type_check_first_pass()
File "C:\Users\Michael\Dropbox\mypy\mypy\build.py", line 2162, in type_check_first_pass
self.type_checker().check_first_pass()
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 253, in check_first_pass
self.accept(d)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 808, in accept
return visitor.visit_class_def(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1389, in visit_class_def
self.accept(defn.defs)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 873, in accept
return visitor.visit_block(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1535, in visit_block
self.accept(s)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 352, in accept
stmt.accept(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\nodes.py", line 591, in accept
return visitor.visit_func_def(self)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 663, in visit_func_def
self._visit_func_def(defn)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 674, in _visit_func_def
self.check_method_override(defn)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1200, in check_method_override
self.check_method_or_accessor_override_for_base(defn, base)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1210, in check_method_or_accessor_override_for_base
self.check_method_override_for_base_with_name(defn, name, base)
File "C:\Users\Michael\Dropbox\mypy\mypy\checker.py", line 1254, in check_method_override_for_base_with_name
assert False, str(base_attr.node)
AssertionError: <mypy.nodes.TypeAlias object at 0x000002139F12C588>
test.py:13: : note: use --pdb to drop into pdb
I did a cursory skim of the existing crash issues, but maybe this is already a known issue? If so, feel free to close.
I think this is a new crash caused by the recent refactoring, previously type aliases were just Vars (hence the assert), but now they have a new dedicated SymbolNode. The fix is straightforward however.
changed the title [-]Overriding a type alias in a subclass causes a crash[/-][+]Overriding definition such as type alias in a subclass causes a crash[/+]on Sep 24, 2018
As discussed in #5662, similar crashes are possible for other kinds of overrides. We should verify that all combinations of base class / subclass node types are handled correctly, including these:
Variable
Method
Type alias
Type variable
Class definition
Module reference
Other special assignments (new type, named tuple, typed dict)
I have an example for a crash on a trivial override (i.e. not changing the type):
from typing import Generic, TypeVar
T = TypeVar('T')
class Parent(Generic[T]):
def __init__(self, value: T) -> None:
self.value: T = value
class Child(Parent[T]):
def __init__(self, value: T) -> None:
self.value: T = value
Mypy:
➜ ~ git:(mypy-bug) ✗ mypy --version
mypy 0.701
➜ ~ git:(mypy-bug) ✗ mypy foo.py --show-traceback
foo.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.701
Traceback (most recent call last):
File "/usr/local/bin/mypy", line 10, in <module>
sys.exit(console_entry())
File "mypy/checker.py", line 395, in accept
File "mypy/nodes.py", line 1019, in accept
File "mypy/checker.py", line 1711, in visit_assignment_stmt__StatementVisitor_glue
File "mypy/checker.py", line 1717, in visit_assignment_stmt
File "mypy/checker.py", line 1777, in check_assignment
File "mypy/checker.py", line 1880, in check_compatibility_all_supers
File "mypy/checker.py", line 1967, in lvalue_type_from_base
AssertionError: Internal error: base lookup outside class
foo.py:13: : note: use --pdb to drop into pdb
Activity
ilevkivskyi commented on Aug 7, 2018
I think this is a new crash caused by the recent refactoring, previously type aliases were just Vars (hence the assert), but now they have a new dedicated SymbolNode. The fix is straightforward however.
JukkaL commented on Sep 24, 2018
As discussed in #5662, similar crashes are possible for other kinds of overrides. We should verify that all combinations of base class / subclass node types are handled correctly, including these:
pdeblanc commented on Apr 21, 2019
I have an example for a crash on a trivial override (i.e. not changing the type):
from typing import Generic, TypeVar T = TypeVar('T') class Parent(Generic[T]): def __init__(self, value: T) -> None: self.value: T = value class Child(Parent[T]): def __init__(self, value: T) -> None: self.value: T = valueMypy:
➜ ~ git:(mypy-bug) ✗ mypy --version mypy 0.701 ➜ ~ git:(mypy-bug) ✗ mypy foo.py --show-traceback foo.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.701 Traceback (most recent call last): File "/usr/local/bin/mypy", line 10, in <module> sys.exit(console_entry()) File "mypy/checker.py", line 395, in accept File "mypy/nodes.py", line 1019, in accept File "mypy/checker.py", line 1711, in visit_assignment_stmt__StatementVisitor_glue File "mypy/checker.py", line 1717, in visit_assignment_stmt File "mypy/checker.py", line 1777, in check_assignment File "mypy/checker.py", line 1880, in check_compatibility_all_supers File "mypy/checker.py", line 1967, in lvalue_type_from_base AssertionError: Internal error: base lookup outside class foo.py:13: : note: use --pdb to drop into pdbilevkivskyi commented on Apr 25, 2019
@pdeblanc I think what you see is a symptom of another horrible crash #5846
Fix the logic in active self-type calculation for current scope (#7235)
Replace hard crash with typecheck error when subclass method has the …
Replace hard crash with typecheck error when subclass method has the …
Replace hard crash with typecheck error when subclass method has the …
Replace hard crash with typecheck error when subclass method has the …