fix(compat): use packaging.version.Version for server version parsing#98
Merged
Conversation
…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>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packaging.version.Versionandpackaging.specifiers.Specifier, which correctly handle PEP 440 pre-release tags (0.3.0-rc1) and local version segments (v0.3.0+sha).0.3.0-rc1to be treated as equal to0.3.0.packagingis used as a transitive dependency (available via setuptools); no new explicit dependency added.Test plan
test_parse_prereleaseverifies0.3.0-rc1parses as0.3.0rc1(not silently stripped).test_parse_local_versionverifiesv0.3.0+sha123parses without error.test_satisfies_prerelease_lt_releaseverifies0.3.0rc1 >= 0.3.0is correctlyFalse._compat.pyremains at 100% coverage.Closes #62