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

Merge uv-pubgrub into uv-pep440 #8669

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Merge uv-pubgrub into uv-pep440 #8669

merged 1 commit into from
Oct 29, 2024

Conversation

konstin
Copy link
Member

@konstin konstin commented Oct 29, 2024

Enabled by #8667 and pubgrub-rs/pubgrub#262, we can remove the uv-pubgrub crate and move the conversion between pep440 specifiers and version ranges directly into pep440.

In a next step, we can remove the VersionRangesSpecifier intermediary and perform the conversion directly.

Enabled by #8667 and pubgrub-rs/pubgrub#262, we can remove the uv-pubgrub crate and move the conversion between pep440 specifiers and version ranges directly into pep440.

In a next step, we can remove the `VersionRangesSpecifier` intermediary and perform the conversion directly.
Self::InvalidTildeEquals(specifier) => {
write!(
f,
"The `~=` operator requires at least two release segments: `{specifier}`"
Copy link
Member Author

Choose a reason for hiding this comment

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

@BurntSushi Can this error ever happen / could we catch that in the parser and make the conversion infallible?

Copy link
Member

Choose a reason for hiding this comment

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

You mean the parser for marker expressions? I think there are tests covering it?

let (result, warnings) = MarkerTree::from_str("python_version ~= '3.7'")

Whether ~= is actually used in the real world, I'm not sure. I don't recall seeing it.

(I'm not 100% certain I've understood everything correctly here.)

Oh, I think I did misunderstand. Perhaps it's the combination of ~= and a lack of two release segments. Indeed, PEP 440 says:

This operator MUST NOT be used with a single segment version number such as ~=1.

So I guess we could indeed catch this at parse time.

A secondary problem is how to represent this in the type system. Otherwise you'll need a panicking branch here instead of an error. Which I think seems fine as long as we document our guarantees.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

I will document the invariant and change to to an infallible conversion.

@konstin konstin merged commit e5b8cdb into main Oct 29, 2024
63 checks passed
@konstin konstin deleted the konsti/version-ranges-2 branch October 29, 2024 19:15
konstin added a commit that referenced this pull request Oct 29, 2024
With #8669 as preparation, we can remove what used to be the `PubGrubSpecifier` and instead implement a direct conversion from `VersionSpecifiers` to `Range<Version>`. Thanks to #8669 (comment), this conversion is infallible, removing a lot of fallibility downstream.

The conversion takes an owned value, to signal that we consume the value. Previously, the function had cloned the version internally.
konstin added a commit that referenced this pull request Oct 30, 2024
With #8669 as preparation, we can remove what used to be the `PubGrubSpecifier` and instead implement a direct conversion from `VersionSpecifiers` to `Range<Version>`. Thanks to #8669 (comment), this conversion is infallible, removing a lot of fallibility downstream.

The conversion takes an owned value, to signal that we consume the value. Previously, the function had cloned the version internally.
konstin added a commit that referenced this pull request Oct 30, 2024
With #8669 as preparation, we can remove what used to be the `PubGrubSpecifier` and instead implement a direct conversion from `VersionSpecifiers` to `Range<Version>`. Thanks to #8669 (comment), this conversion is infallible, removing a lot of fallibility downstream.

The conversion takes an owned value, to signal that we consume the value. Previously, the function had cloned the version internally.
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.

3 participants