python / python/mypy

mypy crashes with "Cannot find component" on subsequent runs

Open
#18,751 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash topic-daemon
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Crash Report

Running mypy after the first run sometimes crashes.

rm -rf .mypy_cache fixes the issue, but if I then run mypy a few more times, it crashes again.

Traceback

$ mypy
Traceback (most recent call last):
File "/path/to/mypy/mypy", line 8, in <module> sys.exit(console_entry())
File "/path/to/mypy/_-main_-.py",line 15, in console_entry main(
File "mypy/main.py", line 119, in main
File "mypy/main.py"
File "mypy/build.py"
, line 203, in run_build , line 191, in build
File "mypy/build.py", line 267, in _build File "mypy/build.py", line 2937, in dispatch
File "mypy/build.py" , line 3328, in process-graph
File "mypy/build.py",
File '
"mypy/build.py"
line 3409, in process_fresh-modules , line 2107, in fix_cross_refs
File "mypy/fixup.py" , line 52, in fixup-module
File
"mypy/fixup.py" , line 128, in visit_symbol_table
File "mypy/lookup.py", line 49, in lookup_fully_qualified
AssertionError: Cannot find component 'operators' for 'sqlalchemy.sql.operators'

To Reproduce

This is at work, and it's a rather large repo, so I can't provide easy repro steps. I would be happy to provide additional information that you need.

Your Environment

  • Mypy version used: v1.15.0
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
mypy_path = server/python_stubs,server

files = server/,test/

explicit_package_bases = True
enable_incomplete_feature=InlineTypedDict

strict = True
warn_return_any = False
disallow_untyped_calls = False
no_implicit_reexport = False
warn_unreachable = True
plugins = pydantic.mypy

Additionally, we added ignore_missing_imports to most of our libraries.

  • Python version used:
  • python 3.11.11
  • Operating system and version:
  • macOS ventura

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the traceback path through mypy/build.py, mypy/fixup.py, and mypy/lookup.py, focusing on processing fresh modules after the .mypy_cache is reused. Reproduce the failure across subsequent runs if possible, then verify that repeated mypy runs no longer raise the reported AssertionError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.