Closed
Description
Stacktrack very closely related to #1682, but unable to find a way to related both issues.
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
def __init__(self, a: T) -> None: ...
@classmethod
def f(cls) -> None: ...
gives
*** INTERNAL ERROR ***
asd4.py:7: error: Internal error -- please report a bug at https://github.com/python/mypy/issues
NOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.4/mypy", line 6, in <module>
main(__file__)
File "/usr/lib64/python3.4/site-packages/mypy/main.py", line 40, in main
res = type_check_only(sources, bin_dir, options)
File "/usr/lib64/python3.4/site-packages/mypy/main.py", line 81, in type_check_only
options=options)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 177, in build
dispatch(sources, manager)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1331, in dispatch
process_graph(graph, manager)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1469, in process_graph
process_stale_scc(graph, scc)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1542, in process_stale_scc
graph[id].semantic_analysis()
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1296, in semantic_analysis
self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 243, in visit_file
self.accept(d)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 2306, in accept
node.accept(self)
File "/usr/lib64/python3.4/site-packages/mypy/nodes.py", line 660, in accept
return visitor.visit_class_def(self)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 564, in visit_class_def
defn.defs.accept(self)
File "/usr/lib64/python3.4/site-packages/mypy/nodes.py", line 723, in accept
return visitor.visit_block(self)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 1014, in visit_block
self.accept(s)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 2306, in accept
node.accept(self)
File "/usr/lib64/python3.4/site-packages/mypy/nodes.py", line 544, in accept
return visitor.visit_decorator(self)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 1626, in visit_decorator
dec.func.accept(self)
File "/usr/lib64/python3.4/site-packages/mypy/nodes.py", line 475, in accept
return visitor.visit_func_def(self)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 316, in visit_func_def
self.analyze_function(defn)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 468, in analyze_function
defn.type = self.anal_type(defn.type)
File "/usr/lib64/python3.4/site-packages/mypy/semanal.py", line 1039, in anal_type
return t.accept(a)
File "/usr/lib64/python3.4/site-packages/mypy/types.py", line 606, in accept
return visitor.visit_callable_type(self)
File "/usr/lib64/python3.4/site-packages/mypy/typeanal.py", line 204, in visit_callable_type
return t.copy_modified(arg_types=self.anal_array(t.arg_types),
File "/usr/lib64/python3.4/site-packages/mypy/typeanal.py", line 274, in anal_array
res.append(t.accept(self))
File "/usr/lib64/python3.4/site-packages/mypy/types.py", line 606, in accept
return visitor.visit_callable_type(self)
File "/usr/lib64/python3.4/site-packages/mypy/typeanal.py", line 204, in visit_callable_type
return t.copy_modified(arg_types=self.anal_array(t.arg_types),
File "/usr/lib64/python3.4/site-packages/mypy/typeanal.py", line 274, in anal_array
res.append(t.accept(self))
File "/usr/lib64/python3.4/site-packages/mypy/types.py", line 448, in accept
return visitor.visit_type_var(self)
File "/usr/lib64/python3.4/site-packages/mypy/typeanal.py", line 201, in visit_type_var
raise RuntimeError('TypeVarType is already analyzed')
RuntimeError: TypeVarType is already analyzed
Removing the Generic
subclassing also triggers it.