Skip to content

(🐞) Invalid per-module options in inline configuration are silently ignored #12342

Closed

Description

@KotlinIsland
# mypy: disable-error-code=name-defined python-verion="3.6"

a  # error: Name "a" is not defined  [name-defined]

But if I include it in the config file it gives a warning:

[[tool.mypy.overrides]]
module  = ["test"]
disable_error_code = "name-defined"
python_verion="3.6"
> mypy test.py
pyproject.toml: [module = "test"]: Per-module sections should only specify per-module flags (disable_error_code, python_version)
test.py:3:1: error: Name "a" is not defined  [name-defined]
Found 1 error in 1 file (checked 1 source file)

This is inconsistent with having a invalid option inline:

# mypy: AMONGUS
> mypy test.py
test.py:1:1: error: Unrecognized option: amongus = True  [misc]
Found 1 error in 1 file (checked 1 source file)

Activity

  1. changed the title [-](🐞) `disable-error-code` doesn't work in inline configuration[/-] [+](🐞) Invalid per-module options in inline configuration are silently ignored[/+] on Mar 21, 2022
  2. wyattscarpenter commented on May 11, 2025

    @wyattscarpenter
    Contributor

    This is half-fixed by now, in that

    # mypy: AMONGUS
    # mypy: disable-error-code=name-defined python-verion="3.6"
    # mypy: disable-error-code=name-defined
    # mypy: python-verion="3.6"
    
    a  # error: Name "a" is not defined  [name-defined]
    

    gets

    main.py:1: error: Unrecognized option: amongus = True  [misc]
    main.py:2: error: disable_error_code: Invalid error code(s): name-defined python-verion=3.6  [misc]
    main.py:4: error: Unrecognized option: python_verion = 3.6  [misc]
    main.py:6: error: Name "a" is not defined  [name-defined]
    Found 4 errors in 1 file (checked 1 source file)
    

    Note that there is no error for line 3, even though it doesn't work!

    # mypy: disable_error_code=name-defined will actually disable that error code.

  3. wyattscarpenter commented on May 12, 2025

    @wyattscarpenter
    Contributor

    Oh, looks like the new incorrect behavior is actually much simpler than I thought

    # mypy: disable-error-code=name-defined
    a

    works. (no output)

    # mypy: disable-error-code=name-defined
    # mypy: AMONGUS
    a

    doesn't. (output:

      main:3: error: Unrecognized option: amongus = True (diff)
      main:4: error: Name "a" is not defined (diff)
    

    )

  4. wyattscarpenter commented on May 12, 2025

    @wyattscarpenter
    Contributor

    This github issue was unrelated issue to what I discovered, and this can be closed as complete, as python_version now gets an Unrecognized option error when used per-module.

  5. added a commit that references this issue on Aug 2, 2025
    813b4d1
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 wrongtopic-configurationConfiguration files and flags

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions