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
The core of the issue might be that an automatic import done by an IDE caused game.theater.frontline to import game.theater.missiontarget.MissionTarget from game.theater.controlpoint instead of the module that defines it. That's the one piece of the original project that does seem outright incorrect, and importing the type from the correct module does fix the crash. In any case, mypy should not crash.
Traceback
game\commander\tasks\packageplanningtask.py:4: error: Name "MissionTarget" is not defined
game\commander\tasks\primitive\cas.py:8: 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.940+dev.2d30dbaa34eab9d7519e440480f360fc9a1e65c3
game\commander\tasks\primitive\cas.py:8: : note: use --pdb to drop into pdb
game\theater\controlpoint.py:1: error: Module "game.coalition" has no attribute "Coalition"
Traceback (most recent call last):
File "C:\Users\dan\src\mypy-repro\venv\Scripts\mypy-script.py", line 33, in <module>
sys.exit(load_entry_point('mypy', 'console_scripts', 'mypy')())
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\__main__.py", line 12, in console_entry
main(None, sys.stdout, sys.stderr)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\main.py", line 96, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\main.py", line 173, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\build.py", line 180, in build
result = _build(
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\build.py", line 256, in _build
graph = dispatch(sources, manager, stdout)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\build.py", line 2722, in dispatch
process_graph(graph, manager)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\build.py", line 3066, in process_graph
process_stale_scc(graph, scc, manager)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\build.py", line 3158, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal_main.py", line 78, in semantic_analysis_for_scc
process_top_levels(graph, scc, patches)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal_main.py", line 199, in process_top_levels
deferred, incomplete, progress = semantic_analyze_target(next_id, state,
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal_main.py", line 326, in semantic_analyze_target
analyzer.refresh_partial(refresh_node,
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 412, in refresh_partial
self.refresh_top_level(node)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 423, in refresh_top_level
self.accept(d)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 5215, in accept
node.accept(self)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\nodes.py", line 1008, in accept
return visitor.visit_class_def(self)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 1111, in visit_class_def
self.analyze_class(defn)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 1189, in analyze_class
self.analyze_class_body_common(defn)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 1198, in analyze_class_body_common
self.apply_class_plugin_hooks(defn)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\semanal.py", line 1244, in apply_class_plugin_hooks
hook(ClassDefContext(defn, decorator, self))
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\plugins\dataclasses.py", line 518, in dataclass_class_maker_callback
transformer.transform()
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\plugins\dataclasses.py", line 121, in transform
attributes = self.collect_attributes()
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\plugins\dataclasses.py", line 404, in collect_attributes
attr.expand_typevar_from_subtype(ctx.cls.info)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\plugins\dataclasses.py", line 107, in expand_typevar_from_subtype
self.type = map_type_from_supertype(self.type, sub_type, self.info)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\typeops.py", line 147, in map_type_from_supertype
inst_type = map_instance_to_supertype(inst_type, super_info)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\maptype.py", line 24, in map_instance_to_supertype
return map_instance_to_supertypes(instance, superclass)[0]
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\maptype.py", line 37, in map_instance_to_supertypes
a.extend(map_instance_to_direct_supertypes(t, sup))
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\maptype.py", line 82, in map_instance_to_direct_supertypes
t = expand_type(b, env)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\expandtype.py", line 17, in expand_type
return typ.accept(ExpandTypeVisitor(env))
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\types.py", line 1065, in accept
return visitor.visit_instance(self)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\expandtype.py", line 89, in visit_instance
args = self.expand_types(t.args)
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\expandtype.py", line 181, in expand_types
a.append(t.accept(self))
File "c:\users\dan\src\mypy-repro\venv\src\mypy\mypy\types.py", line 2200, in accept
assert isinstance(visitor, SyntheticTypeVisitor)
AssertionError:
To Reproduce
https://github.com/DanAlbert/mypy-repro. Note that this is heavily minimized, so some parts might look just wrong, like importing types that don't exist. Defining the types where they belong doesn't make the crash go away, so they're omitted.
$ python -m venv venv # I'm using Python 3.10
$ .\venv\Scripts\activate # Or source venv/bin/activate for non-Windows
$ python -m pip install -r requirements.txt # Only installs HEAD mypy, so skip if you have your own installed
$ mypy --no-incremental game
Your Environment
Mypy version used: mypy 0.940+dev.2d30dbaa34eab9d7519e440480f360fc9a1e65c3
Mypy command-line flags: --no-incremental for testing purposes, but it doesn't matter
Mypy configuration options from mypy.ini (and other config files): namespace_packages = True
Python version used: Python 3.10.2
Operating system and version: Windows 10 Pro 21H2 19044.1526
I haven't verified if this affects other environments or not. I have no reason to believe this is Windows specific though.
The text was updated successfully, but these errors were encountered:
Looks like this was fixed by #12762, according to git-bisect.
Running mypy against the repro now produces the following output:
$ mypy --no-incremental game
game\commander\tasks\packageplanningtask.py:4: error: Name "MissionTarget" is not defined
game\theater\frontline.py:1: error: Module "game.theater.controlpoint" has no attribute "MissionTarget"
game\theater\controlpoint.py:1: error: Module "game.coalition" has no attribute "Coalition"
game\commander\theatercommander.py:1: error: Module "game.commander.tasks.compound.nextaction" has no attribute "PlanNextAction"
game\commander\tasks\compound\nextaction.py:1: error: Module "game.commander.tasks.compound.defendbases" has no attribute "DefendBases"; maybe "DefendBase"?
game\commander\tasks\compound\defendbases.py:1: error: Module "game.commander.tasks.compound.defendbase" has no attribute "DefendBase"
game\commander\__init__.py:1: error: Module "game.commander.theatercommander" has no attribute "TheaterCommander"
Found 7 errors in 7 files (checked 12 source files)
These errors do all seem legitimate, based on a quick skim.
Crash Report
The core of the issue might be that an automatic import done by an IDE caused
game.theater.frontline
to importgame.theater.missiontarget.MissionTarget
fromgame.theater.controlpoint
instead of the module that defines it. That's the one piece of the original project that does seem outright incorrect, and importing the type from the correct module does fix the crash. In any case, mypy should not crash.Traceback
To Reproduce
https://github.com/DanAlbert/mypy-repro. Note that this is heavily minimized, so some parts might look just wrong, like importing types that don't exist. Defining the types where they belong doesn't make the crash go away, so they're omitted.
Your Environment
--no-incremental
for testing purposes, but it doesn't mattermypy.ini
(and other config files):namespace_packages = True
I haven't verified if this affects other environments or not. I have no reason to believe this is Windows specific though.
The text was updated successfully, but these errors were encountered: