Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Crash on namedtuple + @dataclass #18527

Description

@ericbuehl

Crash Report

running under python 3.13.1 results in the following crash when it does not crash under 3.12.8

Traceback

Traceback (most recent call last):
  File "<redacted>/.venv/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "<redacted>/.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 3338, in process_graph
  File "mypy/build.py", line 3433, in process_stale_scc
  File "mypy/semanal_main.py", line 99, in semantic_analysis_for_scc
  File "mypy/semanal_main.py", line 443, in apply_class_plugin_hooks
  File "mypy/semanal_main.py", line 479, in apply_hooks_to_class
  File "mypy/plugins/dataclasses.py", line 966, in dataclass_class_maker_callback
  File "mypy/plugins/dataclasses.py", line 389, in transform
  File "mypy/plugins/dataclasses.py", line 409, in _add_dunder_replace
  File "mypy/plugins/common.py", line 238, in add_method_to_class
  File "mypy/plugins/common.py", line 315, in _prepare_class_namespace
ValueError: list.remove(x): x not in list

To Reproduce

mypy <source dir>

Your Environment

This error occurs on a large proprietary code base. I have removed all custom configuration options and plugins normally specified in pyproject.toml, cleaned .mypy_cache dir and reproduced the error with a vanilla mypy invocation. No crash when using python 3.12.8, but traceback above occurs when switching to python 3.13.1

  • Mypy version used: 1.14.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: tested successfully under python 3.12.8, fails under 3.13.1
  • Operating system and version: OS X Sequoia

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions