-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Model groups as a property of requirements #9545
Conversation
215cce4
to
7413668
Compare
320fb55
to
d79161d
Compare
7413668
to
374649f
Compare
d79161d
to
1c972a9
Compare
374649f
to
042f88a
Compare
42353b6
to
0f2d004
Compare
And because foo depends on anyio==4.1.0, we can conclude that bar and foo are incompatible. | ||
And because your workspace requires bar and foo, we can conclude that your workspace's requirements are unsatisfiable. | ||
╰─▶ Because bar:dev depends on anyio==4.2.0 and foo depends on anyio==4.1.0, we can conclude that foo and bar:dev are incompatible. | ||
And because your workspace requires bar:dev and foo, we can conclude that your workspace's requirements are unsatisfiable. |
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.
\cc @zanieb -- I think you pointed out this general problem long ago.
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.
Nice :D
0f2d004
to
212f9e8
Compare
212f9e8
to
d83f066
Compare
} else { | ||
Either::Right(requirement.extras.clone().into_iter().map(Some)) | ||
Either::Right(iter::once((None, None))) |
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.
As with #9582, I suspect you'll want to do the same thing for groups as I did for extras: conditionally add the base package dependency if the group is declared as conflicting.
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.
Done.
.extras | ||
.clone() | ||
.into_iter() | ||
.map(|extra| (Some(extra), None)), |
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.
If requirement.groups
isn't empty at this point, does this mean that all of those groups get skipped?
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.
The assumption is that they’re mutually exclusive
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.
Interesting. Hard to tell from the type definition. But encoding that invariant in the types is probably annoying.
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.
I could do it? It's a bit tedious because these also get serialized so we'd want to maintain backwards compatibility, but I could do it. Somewhat prefer to just document it clearly though.
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.
Documenting it seems fine, yeah.
I am pretty much always torn about how much to encode in the types. I do like it, because I find it makes refactoring without fear a lot easier. It prevents you from getting the case analysis wrong. But as you rightly point out, it's a pain. And if the invariants change, it can make refactoring a pain (albeit higher confidence) too.
It's a constant balancing act.
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.
Added.
7904a3d
to
4848055
Compare
4848055
to
7e9042f
Compare
Summary
Today, our dependency group implementation is a little awkward... For each package
P
, we check ifP
contains dependencies for each enabled group, then add a dependency onP
with the group enabled. There are a few issues here:P
toP
with the group enabled. ThenP
with the group enabled adds a dependency on the base package.Instead, our internal requirement type can now include dependency groups, which makes dependency groups look much, much more like extras in the resolver.