Skip to content

NotImplementedError: Cannot serialize PlaceholderNode instance #20796

@correctmost

Description

@correctmost

Crash Report

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

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 c67a479
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions