I feel like I'm missing something obvious, but is ...
# general
f
I feel like I'm missing something obvious, but is there a way to negate
--filter-address-regex
? I'm trying to partition a monorepo by address prefix (which works) but I want a "catch all" that runs everything not caught by the other partitions
Can you just negate the regular expression in regex syntax?
(Python's
re
module does have syntax for negative lookahead and lookbehind assertions.)
f
I had tried
--filter-address-regex='(?!my-path)'
But thats producing
Copy code
[ERROR] Problem parsing --filter-address-regex string list value:
1:(?!my-path)
  -^
Expected "'", ",", "\"" or the end of a tuple indicated by ')' at line 1 column 2
Its trying to parse that as a tuple?
f
As enhancement requests go, this PR literally took less time to do than to think how to work around the lack of it. https://github.com/pantsbuild/pants/pull/22372
f
🙏 appreciate it
f
We will spend more time thinking about the proper UX than actual implementation time. 🙂
An update: It looks Pants already has a
-
negation syntax for filters and not just address regex filters. See https://github.com/pantsbuild/pants/pull/22372#issuecomment-2940935477 for details.
For example,
pants list :: --filter-address-regex="['^helloworld/']" --filter-address-regex="-tests$"
works as expected in the
example-python
repository to list targets starting with
helloworld/
and excluding those ending in
tests
https://github.com/pantsbuild/pants/pull/22387 updates the documentation to be clearer.