python / python/mypy

NotImplementedError: Cannot serialize PlaceholderNode instance

Open
#20,796 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Crash Report

The snippet below crashes mypy 1.19.1 and master (c67a479411).

Traceback

Traceback (most recent call last):
  File ".venv-mypy/bin/mypy", line 6, in <module>
    sys.exit(console_entry())
  File "mypy/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy/mypy/main.py", line 135, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
                              ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/main.py", line 219, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/mypy/build.py", line 371, in build
    result = build_inner(
        sources,
    ...<7 lines>...
        workers,
    )
  File "mypy/mypy/build.py", line 468, in build_inner
    graph = dispatch(sources, manager, stdout)
  File "mypy/mypy/build.py", line 3582, in dispatch
    process_graph(graph, manager)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "mypy/mypy/build.py", line 4047, in process_graph
    done, still_working, results = manager.wait_for_done(graph)
                                   ~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "mypy/mypy/build.py", line 1189, in wait_for_done
    process_stale_scc(graph, next_scc, self)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/build.py", line 4249, in process_stale_scc
    meta_tuples[id] = graph[id].write_cache()
                      ~~~~~~~~~~~~~~~~~~~~~^^
  File "mypy/mypy/build.py", line 3082, in write_cache
    new_interface_hash, meta_tuple = write_cache(
                                     ~~~~~~~~~~~^
        self.id,
        ^^^^^^^^
    ...<12 lines>...
        self.manager,
        ^^^^^^^^^^^^^
    )
    ^
  File "mypy/mypy/build.py", line 1929, in write_cache
    tree.write(data_io)
    ~~~~~~~~~~^^^^^^^^^
  File "mypy/mypy/nodes.py", line 457, in write
    self.names.write(data, self._fullname)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/nodes.py", line 4794, in write
    value.write(data, fullname, key)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/nodes.py", line 4706, in write
    self.node.write(data)
    ~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/nodes.py", line 299, in write
    raise NotImplementedError(f"Cannot serialize {self.__class__.__name__} instance")
NotImplementedError: Cannot serialize PlaceholderNode instance

To Reproduce

*a = b

Your Environment

  • Mypy version used: 1.19.1 and c67a479411
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.14.2
  • Operating system and version: Arch Linux

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

Reproduce the crash with *a = b, then trace cache writing from mypy/build.py through mypy/nodes.py, especially write_cache, Node.write, and PlaceholderNode. Done means this input no longer raises NotImplementedError while serializing the cache.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.