astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.4k stars 1.05k forks source link

Invalid table header with mypy ignore missing import #12098

Closed thisi5patrick closed 3 months ago

thisi5patrick commented 3 months ago

I have this case where I want to exclude a library from being checked in mypy. Based on mypy's documentation what you should do is add the library as

[mypy-foobar.*]
ignore_missing_imports = True

The problem now is that after adding the library Vision from pyobjc-framework-vision into my pyproject.toml as such:

[tool.mypy-Vision.*]
ignore_missing_imports = true

when running ruff check . I get:

ruff failed
  Cause: Failed to parse <path>/pyproject.toml
  Cause: TOML parse error at line 79, column 18
   |
79 | [tool.mypy-Vision.*]
   |                  ^
invalid table header
expected `.`, `]`

Ruff version ruff 0.5.0 Python version Python 3.12.3

MichaReiser commented 3 months ago

Can you try to quote the table header?

["mypy-foobar.*"]
ignore_missing_imports = true

or maybe

[mypy-foobar."*"]
ignore_missing_imports = true

A * isn't a valid key according to the toml specification https://toml.io/en/v1.0.0#keys

MichaReiser commented 3 months ago

There's also a pyproject.toml example in the mypy documentation.

I'm closing this issue because it seems mainly about figuring out the right syntax for the mypy configuration in a pyproject.toml (and not mypy.ini)