python / python/mypy

Mypy Does Not Return Non-Zero Exit Code for Invalid mypy.ini Values Followed by Comments, including 'strict'

Open
#16,764 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.