Fix Version beta/dev ordering and previous_patch_version typo#17
Draft
esphbot wants to merge 1 commit into
Draft
Fix Version beta/dev ordering and previous_patch_version typo#17esphbot wants to merge 1 commit into
esphbot wants to merge 1 commit into
Conversation
Version.__lt__ compared self.dev (bool) against other.beta (int) with 'is', which is always true, so the method returned early on self.dev for every same-major.minor.patch comparison. Beta versions never compared in numeric order (1.15.0b1 < 1.15.0b2 was False) and betas sorted after their stable release. This corrupted Project.latest_release(include_prereleases=True), which picks the newest release via max(). Replace the dev/beta branch with a _prerelease_rank ordering key so dev < betaN < stable holds consistently. Also fix previous_patch_version passing path= instead of patch= to dataclasses.replace, which raised TypeError on every call. Add tests/test_model.py covering parsing, version arithmetic and full ordering (the tests/ directory was previously empty).
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.
What
Fix two correctness bugs in
Version(esphomerelease/model.py) and add the first unit tests for the module.Why
Version.__lt__comparedself.dev(a bool) againstother.beta(an int) withis, an identity check that is effectively always true. The method therefore returned early onself.devfor every comparison of versions sharing the samemajor.minor.patch, making the beta/stable logic below it unreachable. Observable effects:1.15.0b1 < 1.15.0b2→False(betas never ordered numerically)1.15.0b1 < 1.15.0→False(a beta sorted after its stable release)sorted([...])placed1.15.0before its own betasThis directly corrupts
Project.latest_release(include_prereleases=True), which selects the newest release withmax()over parsed tags — the base version that feeds changelog generation.Separately,
previous_patch_versioncalledreplace(path=...)instead ofpatch=..., raisingTypeErroron every invocation.How
__lt__with a small_prerelease_rankordering key sodev < betaN < stableholds consistently within amajor.minor.patch.path=→patch=typo.tests/test_model.py(thetests/dir was empty) covering parse/round-trip, version arithmetic, and the full ordering chain1.14.5 < 1.15.0-dev < 1.15.0b1 < 1.15.0b2 < 1.15.0 < 1.15.1 < 2.0.0, plus a regression test formax()over prereleases.Testing
python3 -m pytest tests/test_model.py→ 29 passed.model.pyimports only the stdlib, so the tests run withoutconfig.jsonor sibling checkouts.Quality Report
Changes: 2 files changed, 154 insertions(+), 13 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan