python / python/mypy

`KeyError: 'deprecated'` because of bad cache

Open
#18,473 14 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Crash Report

I ran mypy in my venv and the cache somehow got into a bad state, leading to crashes until the cache was removed. I don't know what triggered this. If it matters, the mypy that caused the bad cache was installed with faster-cache.

Traceback

Traceback (most recent call last):
  File "[...]/.venv/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "[...]/.venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy/main.py", line 109, in main
  File "mypy/main.py", line 193, in run_build
  File "mypy/build.py", line 194, in build
  File "mypy/build.py", line 269, in _build
  File "mypy/build.py", line 2940, in dispatch
  File "mypy/build.py", line 3331, in process_graph
  File "mypy/build.py", line 3409, in process_fresh_modules
  File "mypy/build.py", line 2096, in load_tree
  File "mypy/nodes.py", line 402, in deserialize
  File "mypy/nodes.py", line 4058, in deserialize
  File "mypy/nodes.py", line 3999, in deserialize
  File "mypy/nodes.py", line 263, in deserialize
  File "mypy/nodes.py", line 3420, in deserialize
  File "mypy/nodes.py", line 4058, in deserialize
  File "mypy/nodes.py", line 3999, in deserialize
  File "mypy/nodes.py", line 263, in deserialize
  File "mypy/nodes.py", line 952, in deserialize
  File "mypy/nodes.py", line 879, in deserialize
KeyError: 'deprecated'

To Reproduce

repro.zip

unzip repro.zip
cd repro/
uv venv
source .venv/bin/activate.fish
uv pip install -r requirements.txt
mypy foo.py

Your Environment

  • Mypy version used: 1.14.1 (compiled: yes)
  • Mypy configuration options from mypy.ini (and other config files): strict = true
  • Python version used: 3.13.1
  • Operating system and version: macOS Sequoia 15.2

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 deserialization path in mypy/nodes.py, especially the deserialize methods near the reported KeyError, and reproduce the failure using the commands and repro.zip provided. Trace how the bad cache is read after running mypy with faster-cache. Done means the reproduced cache state no longer crashes with KeyError: 'deprecated'.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.