Skip to content

Support for PEP 440 versions#1556

Open
edvilme wants to merge 8 commits into
mainfrom
pep440
Open

Support for PEP 440 versions#1556
edvilme wants to merge 8 commits into
mainfrom
pep440

Conversation

@edvilme
Copy link
Copy Markdown
Contributor

@edvilme edvilme commented Jun 3, 2026

This pull request refactors how Python version strings are handled and compared throughout the codebase, replacing custom logic with the PEP 440-compliant @renovatebot/pep440 library. This ensures more accurate version validation, comparison, and display, and improves reliability across Python environment management features. Additionally, it updates dependencies and cleans up related code.

Python version handling improvements:

  • Replaced all custom version parsing, comparison, and validation logic (e.g., shortVersion, isGreater, compareVersions) with PEP 440-compliant functions (pep440Valid, pep440Compare, etc.) from the @renovatebot/pep440 library in src/managers/common/utils.ts and throughout the codebase. This affects environment sorting, latest version selection, and version string shortening. [1] [2] [3] [4] [5]
  • Updated all usages of the old shortVersion function to use the new shortenVersionString, which leverages PEP 440 parsing for more accurate and consistent version display. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Updated version sorting and selection logic in conda and environment managers to use PEP 440 comparison for more reliable and standards-compliant ordering. [1] [2] [3] [4]

Validation and compatibility checks:

  • Replaced regex-based PEP 440 validation in pyproject.toml validation with pep440Valid for more robust version checking. [1] [2]
  • Updated extension compatibility checks to use PEP 440-compliant version comparison, ensuring accurate enforcement of minimum required extension versions. [1] [2]

Dependency and configuration updates:

  • Added @renovatebot/pep440 as a dependency in package.json and reformatted some configuration for clarity. [1] [2]

These changes collectively improve the accuracy, maintainability, and standards compliance of Python version handling across the extension.

For reference https://peps.python.org/pep-0440/

edvilme added 2 commits June 3, 2026 10:38
PEP 440 describes a scheme for identifying versions of Python software distributions, and declaring dependencies on particular versions. As such, parsing and comparing are done in different parts of the codebase, leading to (potentially) diverging implementations and duplicated code.

Introduces classes \PEP440Version\, \VersionConstraint\, \VersionSpecifier\ classes for parsing, representing and comparing versions to have a centralized way of handling those behaviors.
@edvilme edvilme added the debt Code quality issues label Jun 3, 2026
@edvilme edvilme changed the title Handle PEP 440 Version Add PEP440Version class and methods Jun 3, 2026
@edvilme edvilme requested a review from eleanorjboyd June 3, 2026 18:38

This comment was marked as outdated.

@edvilme edvilme requested a review from StellaHuang95 June 5, 2026 00:04
@edvilme edvilme changed the title Add PEP440Version class and methods Support for PEP 440 versions Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants