Skip to content

Combine dependency clauses with the same root #3225

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

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

ibraheemdev
Copy link
Member

Summary

Simplifies dependency errors of the form you require package-a and you require package-b to you require package-a and package-b. Resolves #1009.

@@ -366,7 +366,7 @@ fn excluded_only_compatible_version() {
And because you require one of:
package-a<2.0.0
package-a>2.0.0
and you require package-b>=2.0.0,<3.0.0, we can conclude that the requirements are unsatisfiable.
and package-b>=2.0.0,<3.0.0, we can conclude that the requirements are unsatisfiable.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I'm a little unsure about, but I think it's still clearer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm interesting thanks for flagging. It does seem like an improvement, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed the extra whitespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you require package-a but also package-b would be better in general.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that generalizes well for the "proof" that's being stated.

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Apr 23, 2024

@zanieb you mentioned that we might want to combine clauses within PubGrub itself. Is there a chance for false reporting with a transformation like this during formatting or does modifying PubGrub just allow for more types of simplification?

@zanieb zanieb self-requested a review April 23, 2024 22:15
@zanieb
Copy link
Member

zanieb commented Apr 23, 2024

Are you referring to #1673 (comment) or something else?

This looks like a really reasonable step. In contrast to #1673, this implementation seems quite safe. I don't think this could false-report.

I believe the alternative to handling this in the formatter is to derive a new tree with some collapsed nodes. We could look into implementing this in the default PubGrub formatter as well to improve the error messages it displays. I'm not sure we could collapse the nodes in PubGrub's resolver — that's more like #1901 which requires pubgrub-rs/pubgrub#208.

We may also be able to use this pattern this for other incompatibility types e.g. instead of "because foo is unavailable and bar is unavailable" we could say "because foo and bar are unavailable".

@zanieb
Copy link
Member

zanieb commented Apr 23, 2024

Nice work :)

@zanieb zanieb mentioned this pull request Apr 24, 2024
zanieb added a commit that referenced this pull request Apr 24, 2024
Includes astral-sh/packse#179 for #3225

```
uv pip compile scripts/scenarios/requirements.in -o scripts/scenarios/requirements.txt --refresh-package packse --upgrade
cargo dev fetch-python
source .env
./scripts/sync_scenarios.sh
```
Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Might be worth opening some issues for those follow-ups I mentioned so we don't forget about them.

@Eh2406
Copy link

Eh2406 commented Apr 26, 2024

Thank you so much for the progress here. Even this targeted fix is probably worth up streaming in pubgrub at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine dependency clauses with the same root
4 participants