`incremental update --rc` treats rc0 as not being a release candidate

Open Beginner friendly
#214 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start in src/incremental/update.py: the if existing.release_candidate: checks around L105 (--rc bump), L156 (full-release path) and L180 (rewriting existing rc references) are all false for rc0. Change them to an is not None test, and check Version.__init__'s prerelease handling in src/incremental/_version.py while you are there. Run the reproduction from the issue first to confirm 30.6.0rc1, then add a regression test alongside the existing ones in src/incremental/tests/test_update.py; done means the rc0 case yields 24.1.0rc1 and the suite passes.

Written by the indexing model from the issue text.

Description

When the current version is a release candidate with number 0 (e.g. 24.1.0rc0), incremental update <pkg> --rc starts a new calendar version instead of bumping to rc1. With rc1 the bump works as documented.

Environment: incremental 24.11.0, Python 3.12

Reproduction (calls the function behind the CLI so the date is fixed; equivalent to incremental update Shrubbery --rc)

import datetime, json, pathlib, tempfile
from incremental.update import _run

result = []
for rc in [0, 1]:
    with tempfile.TemporaryDirectory() as t:
        p = pathlib.Path(t)
        f = p / '_version.py'
        f.write_text(
            'from incremental import Version\n'
            f'__version__ = Version("Shrubbery", 24, 1, 0, release_candidate={rc})\n'
        )
        _run('Shrubbery', str(p), None, False, True, False, False, False,
             _date=datetime.date(2030, 6, 1), _print=lambda x: None)
        ns = {}
        exec(f.read_text(), ns)
        result.append(ns['__version__'].public())
print(json.dumps(result))

Actual

["30.6.0rc1", "24.1.0rc2"]

Expected

["24.1.0rc1", "24.1.0rc2"]

The README says release_candidate can be "set to 0 or higher to mark this Version being of a release candidate", and that --rc will "bump the release candidate number by 1 if it is" one. An rc0 version can come from --newversion 24.1.0rc0 (or 24.1.0rc, which PEP 440 normalizes to rc0).

Likely cause: if existing.release_candidate: is false for 0. From reading the code, the same check is used for the no-argument "make a full release" path (L156) and when rewriting existing rc references (L180), so those probably mis-handle rc0 as well (I have not run them); is not None would fix all three. Version(..., prerelease=0) has a similar truthiness check in __init__, though that argument is deprecated.

Found while testing the library with an automated exploration tool; the reproduction above was re-run on 24.11.0 before filing.

Dominant language
Python
Stars
145
Forks
22
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from twisted/incremental

All issues in twisted/incremental

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.