Reputation: 537
We're currently using Mypy
(v 0.910) in our project with pyproject.toml
for configuration.
I have the following file structure:
src
--app
--generated
--service
--data
--ingest
pyproject.toml
:
...
[tool.mypy]
python_version = 3.8
disallow_untyped_defs = true
exclude = "(src/app/generated)|(src/ingest)"
...
When running with this configuration, the src/ingest
folder is ignored, but not the src/app/generated
folder. To test the regex, I also tried:
...
[tool.mypy]
python_version = 3.8
disallow_untyped_defs = true
exclude = "(src/app)|(src/ingest)"
...
mypy src --config-file ./pyproject.toml
Success: no issues found in 1 source file
which successfully ignored all files. I'm wondering why the first example is not ignoring src/app/generated
folder.
Upvotes: 19
Views: 17952
Reputation: 16747
In pyproject.toml
you can simply jot down a list of directories, e.g.
[tool.mypy]
exclude = [
"src/app/generated",
"src/ingest",
"venv",
]
Further details, including caveats, are explained in the config file chapter of the mypy documentation.
Upvotes: 1
Reputation: 9
I just ran into this same problem -- it turns out you need single quotes for a pyproject.toml
file:
[tool.mypy]
plugins = [ "mypy_django_plugin.main" ]
ignore_missing_imports = true
check_untyped_defs = true
disallow_untyped_defs = true
exclude = 'util/mixins\.py$|typings/.*\.py'
Upvotes: 0
Reputation: 2901
for whoever uses setup.cfg
file.
The following syntax is the one that worked for me:
[mypy]
exclude = folder_1|venv|tests
Upvotes: 14
Reputation: 325
Following should work:
[tool.mypy]
python_version = 3.8
disallow_untyped_defs = true
exclude = "src/(app|ingest)"
Upvotes: 1