Skip to content

Crash when using an invalid 'enable_error_code' value in pyproject.toml #19491

@Spacerulerwill

Description

@Spacerulerwill

Crash Report

Running mypy . causes an unhandled exception when providing invalid input for the enable_error_code mypy setting in pyproject.toml only. This doesn't happen with the equivalent config in mypy.ini or via the command line, see extra notes at the bottom.

Traceback

Traceback (most recent call last):
  File "/home/william/mypytest/.venv/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "/home/william/mypytest/.venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy/main.py", line 89, in main
  File "mypy/main.py", line 1365, in process_options
  File "mypy/config_parser.py", line 330, in parse_config_file
  File "mypy/config_parser.py", line 558, in parse_section
  File "mypy/config_parser.py", line 221, in <lambda>
  File "mypy/config_parser.py", line 70, in try_split
TypeError: 'bool' object is not iterable

To Reproduce

pyproject.toml

[project]
name = "mypy-bug-test"
version = "0.1.0"
dependencies = [
    "mypy==1.17.0"
]

[tool.mypy]
enable_error_code = true

Run

python -m venv .venv 
source .venv/bin/activate
pip install .
mypy .

Your Environment

  • Mypy version used: 1.17.0
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): enable_error_code = true
  • Python version used: 3.13.5
  • Operating system and version: AlmaLinux 9.6

** Extra Notes **
When using an equivalent mypy.ini file:

[mypy]
enable_error_code = true

The output is:

mypy.ini: [mypy]: enable_error_code: Invalid error code(s): true
There are no .py[i] files in directory '.'

When adding the parameter via the command line: mypy . --enable-error-code true, the output is:

usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: Invalid error code(s): true

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions