Cannot set `output` in `mypy.ini`

Open Beginner friendly
#21,376 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
devtools

Research direction

Start with mypy.config_parser.parse_section() and inspect how it handles the None default of Options.output. Reproduce the issue using the shown mypy.ini configuration, then verify that configuring output produces JSON as expected.

Written by the indexing model from the issue text.

Description

bug topic-configuration topic-error-reporting

Bug Report

The following config is not respected:

[mypy]
output = json

I believe this is as mypy.config_parser.parse_section() does dv = getattr(template, key, None); if dv is None: ..., but the default of Options.output is intentionally None. I don't know if excluding None default values is intentional here or not, so I haven't yet put up a PR until someone can confirm.

To Reproduce
Use the above config, observe output is not JSON.

Expected Behavior

To be able to configure the output format via JSON.

Actual Behavior

No JSON.

Your Environment

  • Mypy version used: 1.20.2
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): As above
  • Python version used: 3.12
Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 9h
Merged PRs (30d)
56

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.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.