python/mypy

race in record_missing_stub_packages (No such file or directory: '.mypy_cache/missing_stubs')

Opened this issue · 0 comments

Bug Report

When running many mypy instances in parallel on the same project, our pipeline sometimes fails with the following traceback:

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
             ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 102, in main
  File "mypy/main.py", line 186, in run_build
  File "mypy/build.py", line 193, in build
  File "mypy/build.py", line 296, in _build
  File "mypy/build.py", line 3539, in record_missing_stub_packages
FileNotFoundError: [Errno 2] No such file or directory: '.mypy_cache/missing_stubs'

To Reproduce

Run ten parallel mypy on 10 different files in your project from a cold start. Repeat until it fails.

Expected Behavior

That .mypy_cache/missing_stubs contains garbage or results from a random run. Or that there was a flag to disable missing_stubs writing.

Actual Behavior

See traceback above.

Your Environment

Ubuntu Linux running inside a docker container.

  • Mypy version used: mypy 1.12.0, mypy-extensions 1.0.0
  • Mypy command-line flags: mypy sourcefile.py
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
mypy_path = "src"
disable_error_code = "import-untyped"

[[tool.mypy.overrides]]
module = [
  "secretpackage.secretmodule1",
  "secretpackage.secretmodule2",
]
follow_imports = "skip"
  • Python version used: 3.11 (didn't record minor version when it happened)