dmypy crashes when switching branches
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report
I'm running mypy on qiskit. If I run the daemon and then switch branches, mypy crashes. The branches are https://github.com/Qiskit/qiskit/commit/fbb0938686a8e00ca00625799edde8803c32fb56 and https://github.com/Randl/qiskit-terra/commit/7046f116a645c390ef8c7e5f2f39c17f07bd8295
The command is
dmypy run -- --ignore-missing-imports --no-strict-optional --allow-untyped-globals --allow-redefinition --show-error-codes --check-untyped-defs --show-traceback qiskit
Traceback
version: 1.9.0+dev.fbb738a4626976f83a7412df73533d87483a31b7
Daemon crashed!
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/mypy/dmypy_server.py", line 236, in serve
resp = self.run_command(command, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/dmypy_server.py", line 285, in run_command
ret = method(self, **data)
^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/dmypy_server.py", line 353, in cmd_run
return self.check(sources, export_types, is_tty, terminal_width)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/dmypy_server.py", line 429, in check
messages = self.fine_grained_increment_follow_imports(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/dmypy_server.py", line 631, in fine_grained_increment_follow_imports
messages = fine_grained_manager.update(changed, [], followed=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/server/update.py", line 267, in update
result = self.update_one(
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/server/update.py", line 369, in update_one
result = self.update_module(next_id, next_path, next_id in removed_set, followed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/server/update.py", line 452, in update_module
remaining += propagate_changes_using_dependencies(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/server/update.py", line 881, in propagate_changes_using_dependencies
triggered |= reprocess_nodes(manager, graph, id, nodes, deps, processed_targets)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/server/update.py", line 1010, in reprocess_nodes
semantic_analysis_for_targets(graph[module_id], nodes, graph, saved_attrs)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal_main.py", line 137, in semantic_analysis_for_targets
process_top_levels(graph, [state.id], patches)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal_main.py", line 220, in process_top_levels
deferred, incomplete, progress = semantic_analyze_target(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal_main.py", line 349, in semantic_analyze_target
analyzer.refresh_partial(
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 597, in refresh_partial
self.refresh_top_level(node)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 608, in refresh_top_level
self.accept(d)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 6544, in accept
report_internal_error(err, self.errors.file, node.line, self.errors, self.options)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/errors.py", line 1261, in report_internal_error
raise err
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 6542, in accept
node.accept(self)
File "/opt/homebrew/lib/python3.11/site-packages/mypy/nodes.py", line 1310, in accept
return visitor.visit_assignment_stmt(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 2860, in visit_assignment_stmt
if self.check_and_set_up_type_alias(s):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 3617, in check_and_set_up_type_alias
res, alias_tvars, depends_on, qualified_tvars, empty_tuple_index = self.analyze_alias(
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 3506, in analyze_alias
analyzed, depends_on = analyze_type_alias(
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 156, in analyze_type_alias
res = type.accept(analyzer)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/types.py", line 955, in accept
return visitor.visit_unbound_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 259, in visit_unbound_type
typ = self.visit_unbound_type_nonoptional(t, defining_literal)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 399, in visit_unbound_type_nonoptional
special = self.try_analyze_special_unbound_type(t, fullname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 624, in try_analyze_special_unbound_type
return self.analyze_literal_type(t)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 1470, in analyze_literal_type
analyzed_types = self.analyze_literal_param(i + 1, arg, t)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 1536, in analyze_literal_param
fallback = self.named_type(arg.base_type_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 1735, in named_type
node = self.lookup_fully_qualified(fully_qualified_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/typeanal.py", line 256, in lookup_fully_qualified
return self.api.lookup_fully_qualified(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/mypy/semanal.py", line 5855, in lookup_fully_qualified
assert ret is not None, fullname
^^^^^^^^^^^^^^^
AssertionError: builtins.int
To Reproduce
Checkout one branch, run dmypy, checkout second branch, run dmypy.
Your Environment
- Mypy version used: 1.9.0+dev.fbb738a4626976f83a7412df73533d87483a31b7 (current dev)
- Python version used: 3.11
- Operating system and version: macOS 14.1.1 (23B81)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure by running dmypy on the two Qiskit branches, then inspect dmypy_server.py and server/update.py along the traceback into semanal.py and typeanal.py. Trace why the incremental update cannot resolve builtins.int after the branch switch. Done means the daemon survives the switch and a regression test covers the reported reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100