rapid-bird-79300
05/06/2021, 9:51 PMpyproject.toml
for black
configuration, is there a way to run fmt
only against the file patterns in the include
attribute?hundreds-father-404
05/06/2021, 10:08 PMrapid-bird-79300
05/06/2021, 10:11 PMfmt
to run a specific set of files described in the include
regex.
I'll bump to 2.5.0
give your suggestion a try. The block list should be fine for now.hundreds-father-404
05/06/2021, 10:52 PMrapid-bird-79300
05/06/2021, 11:04 PMskip_black=True
by default). Or is there another solution for this you can recommend?hundreds-father-404
05/06/2021, 11:09 PM{
"**/*.py": {"skip_black": True},
"some_specific_file.py: {"skip_flake8": True},
)
But that is an enormous project to re-envision targets, which we want to do but is on the backburner atm to focus on what users prioritized for 2021: https://groups.google.com/u/1/g/pants-devel/c/F8Saug3BrFw/m/ZtWDP4YmDwAJ
In the meantime, unfortunately no 😕 You can use far fewer targets with sources="**/*.py"
, but we've found that one target per directory usually works best. https://www.pantsbuild.org/docs/targets#target-granularity-for-first-party-codeBut that is an enormous project to re-envision targets, which we want to do(the awkwardness of targets is I think my biggest qualm with Pants atm)
rapid-bird-79300
05/06/2021, 11:11 PMfmt
goal directly?hundreds-father-404
05/06/2021, 11:14 PMfilter --address-regex
for example. But then you need to remember to run that specific command, and doing ./pants fmt ::
will do the wrong thing
A goal of Pants is to empower you to move away from bash scripts like needing to run ./run_formatters.sh
for example, that ./pants fmt ::
should do The Right Thingrapid-bird-79300
05/06/2021, 11:17 PM./pants fmt ::
once were ready)--address-regex
via CLI doesn't like my regexes 😅.
I see the tests here: https://github.com/pantsbuild/pants/blob/d9ec8acbe867299bda9465ff4200116fc39bbab9/src/python/pants/backend/project_info/filter_targets_test.py#L[…]3 how would the CLI command look for a regex on dir
?hundreds-father-404
05/06/2021, 11:41 PM./pants filter --address-regex='^src/python/pants/util' ::
rapid-bird-79300
05/06/2021, 11:42 PM::
hundreds-father-404
05/06/2021, 11:46 PM./pants filter
like we have with ./pants list
!
❯ ./pants list
WARNING: No targets were matched in goal `list`.
It's 3 lines of code: https://github.com/pantsbuild/pants/blob/bcc5a8499a8230c08055b314f70fe5c60b5970dc/src/python/pants/backend/project_info/list_targets.py#L53-L55
We'd welcome a patch 🙂 Lmk, there are 2 tweaks I'd suggest we dorapid-bird-79300
05/07/2021, 12:02 AMhundreds-father-404
05/07/2021, 12:20 AMlist_targets.py
are:
1. Rather than using console.print_stderr()
, I think it makes sense to use logger.warning()
. That's how we always do warnings with that [WARN]
prefix. To do that, import logging
and near top of the file set logger = logging.getLogger(__name__)
2. The wording is not as clear as it should be imo. I thought what it was trying to get at is if you run ./pants list dir::
and there are no targets there, so the result is empty. But it turns out that that will error instead with ResolveError
. So, I think the only way this error can trigger is you left off args. Maybe this (taken from what happens when you run ./pants test
)?
17:07:13.09 [WARN] No files or targets specified.
You'll need to tweak the wording in list_integration_test.py
.
Then, copy and paste that code into filter_targets.py
. Add a test test_no_targets_specified()
to filter_targets_test.py
(note the same as no targets matching). It looks like we currently assert that stderr was empty, which will need to be adjustedrapid-bird-79300
05/07/2021, 12:31 AM