Skip to content

fix(compat): use packaging.version.Version for server version parsing#98

Merged
zeevdr merged 1 commit into
mainfrom
fix/packaging-version-parse
May 25, 2026
Merged

fix(compat): use packaging.version.Version for server version parsing#98
zeevdr merged 1 commit into
mainfrom
fix/packaging-version-parse

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 25, 2026

Summary

  • Replaces a hand-rolled regex + integer-tuple comparison with packaging.version.Version and packaging.specifiers.Specifier, which correctly handle PEP 440 pre-release tags (0.3.0-rc1) and local version segments (v0.3.0+sha).
  • Removes ~20 lines of bespoke padding and comparison logic that silently stripped pre-release suffixes, causing 0.3.0-rc1 to be treated as equal to 0.3.0.
  • packaging is used as a transitive dependency (available via setuptools); no new explicit dependency added.

Test plan

  • All 235 existing unit tests pass.
  • New test_parse_prerelease verifies 0.3.0-rc1 parses as 0.3.0rc1 (not silently stripped).
  • New test_parse_local_version verifies v0.3.0+sha123 parses without error.
  • New test_satisfies_prerelease_lt_release verifies 0.3.0rc1 >= 0.3.0 is correctly False.
  • _compat.py remains at 100% coverage.

Closes #62

…ion.Version

Drops the hand-rolled regex and tuple arithmetic in _parse_version and
_satisfies in favour of packaging.version.Version and
packaging.specifiers.Specifier. This handles pre-release tags (0.3.0-rc1
→ 0.3.0rc1) and local segments (v0.3.0+sha) correctly per PEP 440, and
removes approximately 20 lines of bespoke comparison logic.

packaging is available as a transitive dep via setuptools.

Closes #62

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 25, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P2 Nice-to-have labels May 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit 9c3739c into main May 25, 2026
15 checks passed
@zeevdr zeevdr deleted the fix/packaging-version-parse branch May 25, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Nice-to-have size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version parsing: use packaging.version.Version

1 participant