Remove some Clap-level conflicts in argument groups #3001
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
It turns out that if you have an environment variable set, Clap will consider that equivalent to passing the flag, even if it's set to (e.g.) something falsy or the default value.
So, e.g., this fails:
Worse, this fails, because it thinks
--no-index
and--index-url
are conflicting:export UV_INDEX_URL=https://google.com uv pip install flask --no-index
This PR removes some of the conflicts, namely those related to environment variables, such that:
--no-index
,--index-url
, etc. If--no-index
is provided, all the index URLs will be ignored (but we won't error).--pre
will always enable prereleases, even if--prerelease
is also provided. (We could warn here, although honestly it's not trivial because we'd need to make--prerelease
take an optional, then we'd lose the default argument from the--help
.)--system
and--python
. If--python
is provided, we use that, and ignore--system
. (We could warn here.)I guess the underlying problem here is that we can't differentiate between arguments passed on the CLI and those set as environment variables. But making bigger changes here seems out-of-scope.
Closes #3000.