Ignore ANN001 for test methods
TribuneX opened this issue · 2 comments
Description
I want to exclude certain methods from ANN001, such as def test_
methods. Type annotations do not add much value in these methods, since the only arguments are fixtures.
Rationale/Use Case
As described above, it would be nice to exclude certain methods from ANN001.
The following code should be allowed:
def test_no_types(fixture):
pass
Hello, thanks for the suggestion.
This seems like something that's best solved upstream by flake8 rather than at the plugin level. Arbitrary exclusion (like coverage.py's) is complex and something I'm reluctant to add into the scope of this plugin. Though not perfect solutions, existing options like noqa
or per-file-ignores
can get you most of the way there. The former is used in the test suite for this project, for example.
As an aside, in the context of Pytest not all test_*
methods that accept inputs are necessarily fixtures. Parameterized functions would also fit the pattern, and hints do generally add value to these definitions.
Thanks for the hints! I missed the per-file-ignores
config. This helps to ignore some rules for our test code.