Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KotlinIsland opened this issue Mar 13, 2022 · 3 comments
Labels
bug mypy got something wrong topic-configuration Configuration files and flags

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 13, 2022

# 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)
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Mar 13, 2022
@JelleZijlstra JelleZijlstra added the topic-configuration Configuration files and flags label Mar 19, 2022
@KotlinIsland KotlinIsland changed the title (🐞) disable-error-code doesn't work in inline configuration (🐞) Invalid per-module options in inline configuration are silently ignored Mar 21, 2022
@wyattscarpenter
Copy link
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.

@wyattscarpenter
Copy link
Contributor

wyattscarpenter commented May 12, 2025

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)

)

@wyattscarpenter
Copy link
Contributor

This github issue was unrelated issue to what I discovered, and this can be closed as complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-configuration Configuration files and flags
Projects
None yet
Development

No branches or pull requests

3 participants