Skip to content

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

Open

Description

@doublethefish

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions