Skip to content
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

(🎁) Fail and show an error when an invalid extra is requested #2828

Open
KotlinIsland opened this issue Apr 5, 2024 · 12 comments
Open

(🎁) Fail and show an error when an invalid extra is requested #2828

KotlinIsland opened this issue Apr 5, 2024 · 12 comments
Labels
needs-decision Undecided if this should be done

Comments

@KotlinIsland
Copy link

> uv --version
uv 0.1.29 (365cb16fd 2024-04-04)
> uv pip install basedmypy[among] basedpyright[us]
Resolved 6 packages in 571ms
Downloaded 1 package in 19.15s
Installed 2 packages in 57.88s
 + basedmypy==2.4.0
 + basedpyright==1.9.0

The imposter here should have been reported and caused the installation to fail

@charliermarsh
Copy link
Member

We show these warnings on compile:

❯ echo "basedmypy[among]" | uv pip compile -
Resolved 4 packages in 5ms
warning: The package `basedmypy==2.4.0` does not have an extra named `among`.
# This file was autogenerated by uv via the following command:
#    uv pip compile -
basedmypy==2.4.0
basedtyping==0.1.3
    # via basedmypy
mypy-extensions==1.0.0
    # via basedmypy
typing-extensions==4.10.0
    # via
    #   basedmypy
    #   basedtyping

(I don't think we should fail, but we should warn.)

@DetachHead
Copy link

i think it should be an error for the same reason attempting to install a package that doesn't exist is an error. i spent hours the other day trying to figure out why an extra from a package i was using wasn't working, only to find out that it wasn't even installed because i specified the wrong name. warnings are very easy to miss

i can't think of a case where you'd ever want to specify an invalid extra, but if there is, i guess there could be an option to warn instead of fail. but i think it should fail by default

@samypr100
Copy link
Contributor

For reference, pip itself just warns

pip install uvicorn[xyz]
WARNING: uvicorn 0.29.0 does not provide the extra 'xyz'

@charliermarsh
Copy link
Member

I think part of the problem is that "whether an extra exists" can change over time, since extras can be added or removed. Should we backtrack to versions that do include an extra? If not, pip install uvicorn[xyz] would start failing at some point if the extra were removed.

@charliermarsh
Copy link
Member

I added the warning for pip install in #2829 (but not going to close this issue until we decide whether to error).

@charliermarsh
Copy link
Member

I think erroring is reasonable, we just need to consider the implications, because it would be a divergence from pip and so could break some workflows.

@charliermarsh charliermarsh added the needs-decision Undecided if this should be done label Apr 5, 2024
@samypr100
Copy link
Contributor

samypr100 commented Apr 5, 2024

Based on the threads you linked, it seems the only legitimate middle ground I see to avoid potential issue with transitives with invalid extras is pypa/pip#9736 (comment) where you'd enforce extras exists when supplied directly by the user, but don't enforce them when resolving them on transitives.

charliermarsh added a commit that referenced this issue Apr 5, 2024
## Summary

These are shown in `pip compile`, but absent from `pip install`.

See: #2828.
@KotlinIsland
Copy link
Author

KotlinIsland commented Apr 5, 2024

@charliermarsh Next can you do a reimplementation of python itself, all your projects make sound, well-thought out decisions that fix so many long standing issues with the ecosystem.

@jaraco
Copy link

jaraco commented Jun 17, 2024

To add some color to this discussion, I'm working on a build/test system that aims to move a lot of the project configuration into tooling and infrastructure. It assumes that every project under test is going to declare any test dependencies under the test extra and installs them when setting up to run tests.

Some projects, however, will have no project-specific test dependencies. In this case, the project gets built without any Provides-Extra: test in the metadata. I'm leaning toward having every project supply the test extra even when there are no dependencies, to suppress the warning under the current pip install technique but also satisfy a future where installers are more strict about installing them, such as this issue is proposing.

If you have any concerns about that approach, please comment in coherent-oss/coherent.test#5.

@karfau
Copy link

karfau commented Jun 24, 2024

I have a setup where those extras are defined in setup.py but when running
uv pip install -e '.[test]'
it tells me

warning: The package `mypackage @ file://[...]` does not have an extra named `test`.

and also doesn't install any dependencies other then the package itself, not even the things in requirements.txt.

This is the case since v0.2.5, it works fine in 0.2.4.

Let me know if this is the right thread for this message or wether I should file a new issue.

@konstin
Copy link
Member

konstin commented Jun 24, 2024

@karfau That looks like a regression, please file a new issue with details how to reproduce your case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Undecided if this should be done
Projects
None yet
Development

No branches or pull requests

7 participants