Skip to content

feat: Distinguish file-level vs release-level yanking (PEP 592)#13784

Open
Ashutosh0x wants to merge 9 commits intopypa:mainfrom
Ashutosh0x:feature/yanking-files-releases-v2
Open

feat: Distinguish file-level vs release-level yanking (PEP 592)#13784
Ashutosh0x wants to merge 9 commits intopypa:mainfrom
Ashutosh0x:feature/yanking-files-releases-v2

Conversation

@Ashutosh0x
Copy link

Summary

This PR implements proper distinction between file-level and release-level yanking as specified in PEP 592, addressing #13755.

Changes

Core Logic (src/pip/_internal/resolution/resolvelib/factory.py)

The yanking logic has been updated to properly handle two distinct scenarios:

  1. File-level yanking: When individual files are yanked but not all files for a version, only those specific yanked files are excluded. Other non-yanked files from the same version can still be selected.

  2. Release-level yanking: When ALL files for a version are yanked, the version is considered "yanked" and the pinned version exception (== or ===) applies.

Implementation Details

  • Group candidates by version to determine if a version has release-level yanking (all files yanked) or file-level yanking (some files yanked)
  • For file-level yanking: exclude only the yanked files, allow non-yanked files
  • For release-level yanking: apply the PEP 592 "pinned exception" - only allow if the specifier explicitly pins to that version
  • Track yanked_versions set to identify release-level yanked versions
  • Track all_versions_yanked to handle the edge case where all available versions are yanked

Tests

Added comprehensive unit tests in tests/unit/test_yanking.py covering:

  • File-level yanking excludes only yanked files
  • Release-level yanking detection
  • Pinned specifier exceptions for release-level yanking
  • Mixed scenarios with both file-level and release-level yanking

Test Data

Added test index tests/data/indexes/partial_yanked/ with scenarios for:

  • Version 1.0: file-level yanking (one file yanked, one not)
  • Version 2.0: release-level yanking (all files yanked)
  • Version 3.0: no yanking

Fixes

Closes #13755

References

Comment on lines 1 to 10
Copy link
Member

Choose a reason for hiding this comment

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

This news item is way too long, keep it to one or two short sentances.

@notatallshaw
Copy link
Member

I was inspired to write up #13755 because of the following bug:

  • Specifier >1 and a yanked release 2.0 and a pre-release 3.0rc1, in this case 3.0rc1 should be selected

The point is to make sure this bug is fixed and yanking follows the specification. Please, at a minimum, add this test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support yanking files and yanking releases

2 participants

Comments