Mypy Does Not Return Non-Zero Exit Code for Invalid mypy.ini Values Followed by Comments, including 'strict'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Description
When using a comment in an mypy.ini file, it interferes with the parsing of boolean values, leading to unintended behavior. Specifically, if a boolean value is followed by a comment, mypy does not return a non-zero exit code, even if the value is invalid. This can lead to unexpected configuration changes and, in the example provided, turns off the 'strict' mode.
To Reproduce
[mypy]
strict = true # this comment turns strict off
Expected Behavior
Mypy should return a non-zero exit code when encountering invalid configuration values, even if they are followed by a comment.
Actual Behavior
Mypy outputs a warning but does not return a non-zero exit code, allowing the invalid configuration to take effect.
mypy.ini: [mypy]: strict: Not a boolean: true # this comment turns strict off
Your Environment
- Mypy version used: 1.7.0, 1.8.0
- Mypy command-line flags: ''
- Mypy configuration options from
mypy.ini(and other config files): n/a - Python version used: Python 3.10.11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the provided mypy.ini configuration and trace mypy's configuration parsing and validation entry point. Add coverage for a boolean value followed by a comment, and verify that invalid values produce a non-zero exit code while valid values remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100