-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: error on non-existent extra #10869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: error on non-existent extra #10869
Conversation
|
cross-talk note from #10861 which is working on a similar thing: The (It's fine if this PR doesn't handle the pip commands, just doing these ones is an Improvement!) |
Thanks for the heads up! Depending on how complex it is, it might be easier to implement as a follow-up PR yep, not sure, I'm not familiar with the pip interface. |
1ab569d to
9f1a4f0
Compare
9f1a4f0 to
a10ba07
Compare
| // thing is that `x2` should _not_ activate the `idna==3.4` dependency | ||
| // in `proxy1`. The `--extra=x2` should be a no-op, since there is no | ||
| // `x2` extra in the top level `pyproject.toml`. | ||
| // Error out, as x2 extra is only on the child. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the test is still relevant as this now errors out, but since there's also a lock assertion right after, I've added a sync call without argument below, as I wasn't sure.
|
For the record I landed my checking here: uv/crates/uv-requirements/src/source_tree.rs Lines 118 to 131 in e3a0988
My implementation is a bit flawed, notably because it runs "per pyproject.toml" and in concurrent async. Because this wasn't the primary focus of my PR I put in a hacky filter to leave better checking as future work: uv/crates/uv/tests/it/pip_install.rs Lines 8617 to 8620 in e3a0988
The "better" implementation of this would shove a bunch of extra state in |
|
I think we should be doing this against the lockfile instead -- same for dependency groups, probably. Then it will work with |
Tried to implement the validation at lock file level in #10925, but one case that cannot be handled is if we have an extra with no dependencies, like so: [project.optional-dependencies]
http = []as in that case, the empty list would not get added to the lock file, so this will be reported as not existing. Don't know how ok this is, but if it is fine, we'll probably have to rephrase the errors to not confuse the users. |
|
Ah dang... I did think about this before posting, and I thought we included these in |
|
@mkniewallner -- Do you want me to first PR a change to add |
Won't have time to do so right away, so feel free to :) Just curious though, since this would be a new field, that would I believe only be present if we have I believe we won't be able to differentiate between:
I believe since the check would now live after locking it might be fine, but even though, this means that people working on the same project would all have to update uv to the minimum version that sets the new attribute to avoid adding/removing it depending on the version used for locking? But I guess that since the check would land in 0.6.0, this is less problematic than shipping this in a patch version though, as this could be advertised. |
|
We would need to consider always-setting |
|
Depends on #11063 |
|
Closing in favour of #10925. |
Summary
Closes #10597.
Check for invalid extras specified on the CLI, through either
--extra <extra>or--all-extras --no-extra <extra>If an usage of dynamic optional dependencies is detected, validation is not performed, as in this case, we cannot determine which extras exist, as this is delegated to the build backend.
This concretely means that we do not perform the validation if:
Adding this check required to update quite a lot of things. I've tried to split the changes as much as possible, especially since there are some changes I'm not sure about, in terms of architecture.
First, to my knowledge, optional dependencies work similarly to dependency groups for the validation, so I thought it would be ok to make
DependencyGroupsTargetmore generic by renaming it toSpecificationTarget, so that the same logic can be reused both for dependency groups and optional dependencies, but maybe you have a different opinion.I also needed to add
dynamicfield toProject, and a few methods to check the usage of a dynamic key in a project or workspace. Not sure if there are better ways or places to do that.Test Plan
Snapshot tests.