Skip to content

Fix: allow setting output in mypy.ini / mypy.toml#21398

Closed
tjhub1983 wants to merge 4 commits intopython:masterfrom
tjhub1983:fix/21376-output-config
Closed

Fix: allow setting output in mypy.ini / mypy.toml#21398
tjhub1983 wants to merge 4 commits intopython:masterfrom
tjhub1983:fix/21376-output-config

Conversation

@tjhub1983
Copy link
Copy Markdown

Summary

The output option (e.g., output = json) in mypy.ini or mypy.toml was silently ignored.

Root cause: Options.output defaults to None. The config parser checks
dv = getattr(template, key, None) and skips options when dv is None.
Since output was not in config_types, it fell through and was silently ignored.

Fix: Add "output": str to both ini_config_types and toml_config_types.

Changes

  • mypy/config_parser.py: added "output": str to ini_config_types and toml_config_types

Testing

[mypy]
output = json

Now correctly produces JSON output.

Fixes #21376.

tjhub1983 and others added 4 commits May 2, 2026 17:51
Python 3 allows calling NoneType() and type(None)():
    >>> NoneType()
    None
    >>> type(None)()
    None

But mypy raised an "unsupported_type_type" error in analyze_type_type_callee
when encountering a Type[None] callee. Fixed by adding isinstance(item, NoneType)
branch that returns a zero-argument CallableType returning NoneType.

Fixes python#19660.
`output` in Options defaults to None (meaning unset). The config parser
skips options when getattr(template, key, None) returns None, so
`output = json` in mypy.ini was silently ignored.

Fixed by adding `"output": str` to both ini_config_types and
toml_config_types, so the option is recognized and properly set.

Fixes python#21376.
`output` in Options defaults to None. The config parser skips options
when getattr(template, key, None) returns None, so `output = json`
in mypy.ini was silently ignored.

Fixed by adding `"output": str` to both ini_config_types and
toml_config_types.

Fixes python#21376.
@tjhub1983
Copy link
Copy Markdown
Author

Hi maintainers, this PR adds output to and so that in mypy.ini is respected. The root cause is that defaults to , and the config parser skips options where , so the option was silently ignored. Small fix, fully tested. Please consider reviewing. Thanks!

@tjhub1983
Copy link
Copy Markdown
Author

This PR is superseded by #21397 which contains the same fix from the correct branch. Closing in favor of #21397.

@tjhub1983 tjhub1983 closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot set output in mypy.ini

1 participant