Skip to content

Comments

feat: error on non-existent extra from lock file#10925

Closed
mkniewallner wants to merge 4 commits intoastral-sh:gankra/lock-extrafrom
mkniewallner:feat/error-on-non-existent-extra-from-lock
Closed

feat: error on non-existent extra from lock file#10925
mkniewallner wants to merge 4 commits intoastral-sh:gankra/lock-extrafrom
mkniewallner:feat/error-on-non-existent-extra-from-lock

Conversation

@mkniewallner
Copy link
Contributor

@mkniewallner mkniewallner commented Jan 24, 2025

Summary

Based on #11063.

Alternative to #10869 which follows the suggestion, in #10869 (comment), to validate extras from the lock file instead of pyproject.toml.

Test Plan

Snapshot tests.

Some tests are failing, but it seems unrelated to the changes, and likely due to the branch being based on an outdated branch (rebasing the branch from latest main makes one of the failing test pass locally).

Comment on lines +152 to +157
#[error("Extra `{0}` is not defined in the project's `optional-dependencies` table")]
MissingExtraProject(ExtraName),

#[error("Extra `{0}` is not defined in any project's `optional-dependencies` table")]
MissingExtraWorkspace(ExtraName),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wording could probably be adapted here, as the check happens at lock file level, but not sure exactly how we would want to phrase this.

@mkniewallner mkniewallner changed the base branch from main to gankra/lock-extra February 4, 2025 02:41
@mkniewallner mkniewallner force-pushed the feat/error-on-non-existent-extra-from-lock branch from 9121e63 to d34e9ad Compare February 4, 2025 02:42
@mkniewallner mkniewallner marked this pull request as ready for review February 9, 2025 14:44
@Gankra
Copy link
Contributor

Gankra commented Feb 11, 2025

Oh rad, thanks for the rewrite/rebase! (We'll land the base branch this week at which point this can land too)

@Gankra Gankra self-requested a review February 11, 2025 15:53
@zanieb zanieb mentioned this pull request Feb 11, 2025
@Gankra Gankra force-pushed the feat/error-on-non-existent-extra-from-lock branch from d34e9ad to 339255e Compare February 11, 2025 19:29
@Gankra Gankra deleted the branch astral-sh:gankra/lock-extra February 11, 2025 19:38
@Gankra Gankra closed this Feb 11, 2025
@Gankra
Copy link
Contributor

Gankra commented Feb 11, 2025

forehead slap

What a terrible github behaviour. I can't even reopen this! Sorry! (It needs to be retargetted to tracking/060)

@Gankra
Copy link
Contributor

Gankra commented Feb 11, 2025

In the meantime I'll still review this...

@mkniewallner
Copy link
Contributor Author

forehead slap

What a terrible github behaviour. I can't even reopen this! Sorry! (It needs to be retargetted to tracking/060)

No worries, will rebase and recreate the PR :)

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

Basic idea looks right but needs to handle a corner case.

Comment on lines +2621 to +2627
/// Returns `true` if the package contains the [`ExtraName`].
pub fn contains_extra(&self, name: &ExtraName) -> bool {
self.metadata
.provides_extras
.as_ref()
.is_some_and(|provides_extras| provides_extras.contains(name))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is the right place to handle this but I believe this isn't our desired semantic for the case where provides_extras is undefined. We aren't doing a lockfile version bump, so we're still supporting provides_extras being missing.

Some part of this code should handle that as "I don't actually have information on if the extra is defined, and will conservatively not error, because I'm uncertain".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah definitely, will update the logic.

Gankra added a commit that referenced this pull request Feb 12, 2025
## Summary

Closes #10597.

Recreated #10925 that got closed as
the base branch got merged.

## Test Plan

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
Gankra added a commit that referenced this pull request Feb 12, 2025
## Summary

Closes #10597.

Recreated #10925 that got closed as
the base branch got merged.

## Test Plan

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
zanieb pushed a commit that referenced this pull request Feb 13, 2025
Closes #10597.

Recreated #10925 that got closed as
the base branch got merged.

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
zanieb pushed a commit that referenced this pull request Feb 13, 2025
Closes #10597.

Recreated #10925 that got closed as
the base branch got merged.

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
zanieb pushed a commit that referenced this pull request Feb 13, 2025
Closes #10597.

Recreated #10925 that got closed as
the base branch got merged.

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
loic-lescoat pushed a commit to loic-lescoat/uv that referenced this pull request Mar 2, 2025
Closes astral-sh#10597.

Recreated astral-sh#10925 that got closed as
the base branch got merged.

Snapshot tests.

---------

Co-authored-by: Aria Desires <[email protected]>
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.

2 participants