Hello all - apologies for what feels like a questi...
# general
c
Hello all - apologies for what feels like a question I should have been able to answer myself - I’d like to exclude paths from
./pants check ::
- specifically using mypy. It seems that Pants runs mypy per-file, which as far as I understand ignores any
exclude
arg passed to mypy. I don’t want to typecheck my tests - is that something I can do?
1
r
So this is my config inside a
pyproject.toml
Copy code
[tool.mypy]
namespace_packages = true
strict = true

# Error output
show_column_numbers = true
show_error_context = true
show_error_codes = true
show_traceback = true
pretty = true
color_output = true
error_summary = true

ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "tests.*"
ignore_errors = true
This is just ignoring any tests directory related errors. Not ideal since it will still run it on all tests file, but will just ignore it.
c
thanks - that’s better than my current state! hopefully there’s a smoother option, but I guess it’s motivation to go and fix up test annotation…
r
yeah I have realised that ignoring those errors wasn’t that great idea. Navigating around tests isn’t that easy especially now we have much. more tests etc. But I was the one who had to do this wholesale mypy integration and didn’t have enough time.
f
each linter defines a skip field
skip_mypy=True
on a target
on recent Pants versions, you can use
__defaults__
to set
skip_mypy
(or any field for that matter) on multiple targets in a directory tree
👍 1
r
This is definitely better option. Mine is “legacy” before
___defaults___
h
Yeah, something like this in a top-level BUILD file:
Copy code
__defaults__(python_tests=dict(skip_mypy=True))
Will cover all python_tests targets in or underneath that dir
c
awesome, that concept was immediately useful for disabling broken tests in another subtree too - thank you all!