FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix output config option in mypy.ini by mitre88 · Pull Request #21416 · python/mypy · GitHub

Repository navigation

Fix output config option in mypy.ini - #21416

Closed
mitre88 wants to merge 1 commit into
python:masterfrom
mitre88:fix/output-config-ini
Closed

mitre88 wants to merge 1 commit into
python:masterfrom
mitre88:fix/output-config-ini

Conversation

mitre88 commented May 5, 2026

Copy link
Copy Markdown

The config parser was skipping options whose default value is None (e.g. 'output'), even when the attribute exists on the Options class.

This was due to the condition 'dv is None' being used to skip unknown options, but some valid options intentionally have None defaults.

The fix changes the condition to skip only options that don't exist on the template Options object (using hasattr), allowing options like 'output' to be set in config files.

Fixes #21376

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

A5rocks commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Please add a test. I notice the diff is quite different than #21398 so I'm not sure what's going on here :/

Comment thread mypy/config_parser.py Outdated
else:
dv = getattr(template, options_key, None)
if dv is None:
if dv is None and not hasattr(template, options_key):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
if dv is None and not hasattr(template, options_key):
if not hasattr(template, options_key):

I feel like this is simpler?

The config parser was skipping options whose default value is None
(e.g. 'output'), even when the attribute exists on the Options class.
This was due to the condition 'dv is None' being used to skip unknown
options, but some valid options intentionally have None defaults.

The fix changes the condition to skip only options that don't exist
on the template Options object (using hasattr), allowing options like
'output' to be set in config files.

Fixes python#21376

mitre88 commented May 11, 2026

Copy link
Copy Markdown
Author

I replaced this with #21465 after cleaning up the branch history and adding the requested test. The new PR is based directly on current master and only changes mypy/config_parser.py plus mypy/test/test_config_parser.py.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

2 participants


Back | FazBrowse Home | New Git URL