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
{{ message }}
Repository navigation
New semantic analyzer: unbound base class results in crash #7129
[case testNewAnalyzerCyclicWithMetaclass]
from typing import Generic
class C(metaclass=D): # E: Cannot resolve name "D" (possible cyclic definition)
pass
D = D # E: Cannot resolve name "D" (possible cyclic definition)
test_mypy.py:13: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.740+dev.df6284201d1a9803831728d76a9763e7b6fb79c4
Traceback (most recent call last):
File "/home/peter/bin/mypy", line 11, in <module>
load_entry_point('mypy', 'console_scripts', 'mypy')()
File "/home/peter/code/mypy/mypy/__main__.py", line 8, in console_entry
main(None, sys.stdout, sys.stderr)
File "/home/peter/code/mypy/mypy/main.py", line 88, in main
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/peter/code/mypy/mypy/build.py", line 164, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr)
File "/home/peter/code/mypy/mypy/build.py", line 229, in _build
graph = dispatch(sources, manager, stdout)
File "/home/peter/code/mypy/mypy/build.py", line 2566, in dispatch
process_graph(graph, manager)
File "/home/peter/code/mypy/mypy/build.py", line 2875, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/peter/code/mypy/mypy/build.py", line 2968, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "/home/peter/code/mypy/mypy/semanal_main.py", line 78, in semantic_analysis_for_scc
process_functions(graph, scc, patches)
File "/home/peter/code/mypy/mypy/semanal_main.py", line 238, in process_functions
patches)
File "/home/peter/code/mypy/mypy/semanal_main.py", line 274, in process_top_level_function
final_iteration, patches)
File "/home/peter/code/mypy/mypy/semanal_main.py", line 330, in semantic_analyze_target
active_type=active_type)
File "/home/peter/code/mypy/mypy/semanal.py", line 381, in refresh_partial
self.accept(node)
File "/home/peter/code/mypy/mypy/semanal.py", line 4625, in accept
node.accept(self)
File "/home/peter/code/mypy/mypy/nodes.py", line 668, in accept
return visitor.visit_func_def(self)
File "/home/peter/code/mypy/mypy/semanal.py", line 557, in visit_func_def
self.analyze_func_def(defn)
File "/home/peter/code/mypy/mypy/semanal.py", line 589, in analyze_func_def
self.defer(defn)
File "/home/peter/code/mypy/mypy/semanal.py", line 4359, in defer
assert not self.final_iteration, 'Must not defer during final iteration'
AssertionError: Must not defer during final iteration
test_mypy.py:13: : note: use --pdb to drop into pdb
It is interesting that the crash goes away when either:
@attr.s decorator on class B is removed or
the order of the declarations of TYPE_VARIABLE and class A is switched.
Since the new semantic analyzer is the only analyzer available since mypy 0.730, it is not possible to use newer versions of mypy for checking code which contains patterns mentioned in this issue.
Activity
JukkaL commentedon Jul 2, 2019
Another similar test case that causes a crash:
pbasista commentedon Sep 27, 2019
A similar issue also occurs on the following Python 2 code:
It crashes with the following traceback:
It is interesting that the crash goes away when either:
@attr.sdecorator on classBis removed orTYPE_VARIABLEand classAis switched.Since the new semantic analyzer is the only analyzer available since mypy 0.730, it is not possible to use newer versions of
mypyfor checking code which contains patterns mentioned in this issue.ilevkivskyi commentedon Sep 27, 2019
@pbasista I think your example is actually a different crash, see #7535
hauntsaninja commentedon Sep 6, 2021
I can't repro either of the original crashes, so closing