Skip to content

Internal error: KeyError 'setter_type' during node deserialization #19359

Open
@ahmedelq

Description

@ahmedelq

Crash Report

Sometimes mypy crashes with a KeyError.

Traceback

Traceback (most recent call last):
  File "/home/user/project/.venv/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "/home/user/project/.venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy/main.py", line 127, in main
  File "mypy/main.py", line 211, in run_build
  File "mypy/build.py", line 191, in build
  File "mypy/build.py", line 267, in _build
  File "mypy/build.py", line 2939, in dispatch
  File "mypy/build.py", line 3330, in process_graph
  File "mypy/build.py", line 3408, in process_fresh_modules
  File "mypy/build.py", line 2096, in load_tree
  File "mypy/nodes.py", line 391, in deserialize
  File "mypy/nodes.py", line 4137, in deserialize
  File "mypy/nodes.py", line 4077, in deserialize
  File "mypy/nodes.py", line 252, in deserialize
  File "mypy/nodes.py", line 3498, in deserialize
  File "mypy/nodes.py", line 4137, in deserialize
  File "mypy/nodes.py", line 4077, in deserialize
  File "mypy/nodes.py", line 252, in deserialize
  File "mypy/nodes.py", line 968, in deserialize
  File "mypy/nodes.py", line 1132, in deserialize
KeyError: 'setter_type'

To Reproduce

The crash occurs consistently when running mypy on my project. Unfortunately, I haven't been able to isolate this to a minimal reproduction case yet, as it seems to be related to the specific combination of code patterns in my project. The error appears to be triggered during the deserialization of cached type information.

Steps that trigger the crash:

  1. Run mypy app on the project
  2. The crash occurs during the type checking process (not all the times)

Your Environment

  • Mypy version used: mypy 1.16.0 (compiled: yes)
  • Mypy command-line flags: none.
  • Mypy configuration options from mypy.ini (and other config files): (please include your config)
[mypy]
python_version=3.13
strict_optional = True
show_column_numbers = True
check_untyped_defs = True
disallow_untyped_defs = True
warn_unreachable = True
warn_redundant_casts = True
mypy_path = /app
exclude = venv|.venv
plugins = pydantic.mypy
incremental = True
cache_dir = .mypy_cache

[mypy-pgvector.*]
ignore_missing_imports = True

[mypy-asyncpg.*]
ignore_missing_imports = True
  • Python version used: 3.13
  • Operating system and version: Debian GNU/Linux trixie/sid

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions