Closed
Description
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
Bug
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
Here is the minimal reproducible example
from dataclasses import dataclass
from typing import Generic, TypeVar
T = TypeVar("T", bound="B")
class A:
pass
@dataclass
class Transaction(Generic[T]):
a: A
- What is the actual behavior/output?
mypy_bug.py:4: error: Name 'B' is not defined
mypy_bug.py:12: 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.720
Traceback (most recent call last):
File "mypy/newsemanal/semanal.py", line 4550, in accept
File "mypy/nodes.py", line 662, in accept__Node_glue
File "mypy/nodes.py", line 663, in accept
File "mypy/newsemanal/semanal.py", line 519, in visit_func_def__StatementVisitor_glue
File "mypy/newsemanal/semanal.py", line 539, in visit_func_def
File "mypy/newsemanal/semanal.py", line 571, in analyze_func_def
File "mypy/newsemanal/semanal.py", line 4299, in defer
AssertionError: Must not defer during final iteration
mypy_bug.py:12: : note: use --pdb to drop into pdb
mypy_bug.py:12: 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.730+dev.8782ae7f789ad5b8cab97d3c8419f9f98b6eb285
Traceback (most recent call last):
File "/home/hack/work/brainbot/pyvenv3-dev/bin/mypy", line 11, in <module>
load_entry_point('mypy', 'console_scripts', 'mypy')()
File "/home/hack/work/brainbot/mypy/mypy/__main__.py", line 8, in console_entry
main(None, sys.stdout, sys.stderr)
File "/home/hack/work/brainbot/mypy/mypy/main.py", line 88, in main
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/hack/work/brainbot/mypy/mypy/build.py", line 164, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr)
File "/home/hack/work/brainbot/mypy/mypy/build.py", line 229, in _build
graph = dispatch(sources, manager, stdout)
File "/home/hack/work/brainbot/mypy/mypy/build.py", line 2566, in dispatch
process_graph(graph, manager)
File "/home/hack/work/brainbot/mypy/mypy/build.py", line 2875, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/hack/work/brainbot/mypy/mypy/build.py", line 2968, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "/home/hack/work/brainbot/mypy/mypy/semanal_main.py", line 78, in semantic_analysis_for_scc
process_functions(graph, scc, patches)
File "/home/hack/work/brainbot/mypy/mypy/semanal_main.py", line 238, in process_functions
patches)
File "/home/hack/work/brainbot/mypy/mypy/semanal_main.py", line 274, in process_top_level_function
final_iteration, patches)
File "/home/hack/work/brainbot/mypy/mypy/semanal_main.py", line 330, in semantic_analyze_target
active_type=active_type)
File "/home/hack/work/brainbot/mypy/mypy/semanal.py", line 380, in refresh_partial
self.accept(node)
File "/home/hack/work/brainbot/mypy/mypy/semanal.py", line 4624, in accept
node.accept(self)
File "/home/hack/work/brainbot/mypy/mypy/nodes.py", line 668, in accept
return visitor.visit_func_def(self)
File "/home/hack/work/brainbot/mypy/mypy/semanal.py", line 556, in visit_func_def
self.analyze_func_def(defn)
File "/home/hack/work/brainbot/mypy/mypy/semanal.py", line 588, in analyze_func_def
self.defer(defn)
File "/home/hack/work/brainbot/mypy/mypy/semanal.py", line 4358, in defer
assert not self.final_iteration, 'Must not defer during final iteration'
AssertionError: Must not defer during final iteration
mypy_bug.py:12: : note: use --pdb to drop into pdb
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
Python 3.7.4
mypy 0.720 and 8782ae7
- What are the mypy flags you are using? (For example --strict-optional)
Executed with mypy bug.py --show-traceback