Skip to content

Commit ead1b25

Browse files
authored
Temporary fix for spurious errors on negative specs. (#21951)
We fix directly in 2.24.x, as we can't cherrypick the more comprehensive #21943 due to its reliance on a whole stack of changes that we don't want in 2.24.x
1 parent 76f5726 commit ead1b25

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/python/pants/option/options.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ def verify_args(self):
301301

302302
for scope, flags in self._native_parser.get_unconsumed_flags().items():
303303
flags = tuple(flag for flag in flags if flag not in scope_aliases_that_look_like_flags)
304+
# The native options parser currently sees negative specs (e.g., `-path/to/target`)
305+
# as short flags. We filter these out here so we don't report a spurious error.
306+
# In 2.24.x we don't consume flags from the native parser, so this doesn't cause
307+
# correctness issues beyond this spurious error.
308+
# This is fixed properly in 2.25.x, where all parsing is done in the native parser,
309+
# but we can't cherrypick that to 2.24.x as it would be too disruptive.
310+
flags = [flag for flag in flags if flag.startswith("--")]
304311
if flags:
305312
# We may have unconsumed flags in multiple positional contexts, but our
306313
# error handling expects just one, so pick the first one. After the user

0 commit comments

Comments
 (0)