cool-easter-32542
06/15/2023, 2:32 PM_test.py files from mypy/type checks.
I have tried multiple combinations/ways to provide exclude but none of them seems to work with pants.
Here are few of my attempts:
1. Provide exclude in mypy.ini file
[mypy] exclude = _test\.py$
If i run mypy src/, mypy excludes my test files. But pants check :: runs on my test files. pants check however respects other flags provided in my mypy.ini file though, like follow_imports.
2. Provide exclude in CLI argument
a. mypy --exclude '_test\.py$' src/ This works fine as I expect. test files are excluded.
b. ` pants -ldebug --print-stacktrace check --mypy-args "--exclude '_test.py$'" ::
Unknown flag --exclude '_test\.py$' on check scope
Use `pants help check` to get help.
10:27:07.01 [ERROR] Unknown flags --exclude '_test\.py$' on scope check
Traceback (most recent call last):
File "/Users/aditya/Library/Caches/nce/fc197caf7591487de8182f7932e70c61b197372bb3ec4c3ed53f6a8feac3234f/bindings/venvs/2.16.0/lib/python3.9/site-packages/pants/bin/daemon_pants_runner.py", line 131, in single_daemonized_run
runner = LocalPantsRunner.create(
File "/Users/aditya/Library/Caches/nce/fc197caf7591487de8182f7932e70c61b197372bb3ec4c3ed53f6a8feac3234f/bindings/venvs/2.16.0/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 106, in create
options.for_scope(scope)
File "/Users/aditya/Library/Caches/nce/fc197caf7591487de8182f7932e70c61b197372bb3ec4c3ed53f6a8feac3234f/bindings/venvs/2.16.0/lib/python3.9/site-packages/pants/util/memo.py", line 123, in memoize
result = func(*args, **kwargs)
File "/Users/aditya/Library/Caches/nce/fc197caf7591487de8182f7932e70c61b197372bb3ec4c3ed53f6a8feac3234f/bindings/venvs/2.16.0/lib/python3.9/site-packages/pants/option/options.py", line 350, in for_scope
values = self.get_parser(scope).parse_args(parse_args_request)
File "/Users/aditya/Library/Caches/nce/fc197caf7591487de8182f7932e70c61b197372bb3ec4c3ed53f6a8feac3234f/bindings/venvs/2.16.0/lib/python3.9/site-packages/pants/option/parser.py", line 289, in parse_args
raise UnknownFlagsError(tuple(flag_value_map.keys()), self.scope)
pants.option.errors.UnknownFlagsError: Unknown flags --exclude '_test\.py$' on scope check
Any suggestions on how to investigate this further ? I think my mypy.ini file is correct because it behaves correctly with the mypy on my system(1.1.1), which is also the default version of pants2.16.0, which I am using. I am not sure how to use the mypy executable used by pants though.
pantsbuild/pants