Skip to content

fix(version): do not crash on prerelease bump of a dev release - #11217

Merged
radoering merged 1 commit into
python-poetry:mainfrom
chinmayajha:version-prerelease-dev
Nov 15, 2026
Merged

radoering merged 1 commit into
python-poetry:mainfrom
chinmayajha:version-prerelease-dev

Conversation

@chinmayajha

Copy link
Copy Markdown
Contributor
  • Added tests for changed code.
  • Updated documentation for changed code.

poetry version prerelease crashes when the current version is a dev release without a pre segment:

$ poetry version
demo 1.0.0.dev1
$ poetry version prerelease
AssertionError
  at src/poetry/console/commands/version.py:114 in increment_version

is_unstable() is true for dev releases, but parsed.pre is None there, so the assert fails. Same for 1.0.0.post1.dev1.

The branch now checks parsed.pre directly, so these fall through to the existing next_patch().first_prerelease() path:

  • 1.0.0.dev1 -> 1.0.0a0
  • 1.0.0.post1.dev1 -> 1.0.1a0 (same as 1.0.0.post1 today)

Versions that worked before are unchanged. Added test cases and a row to the version table in the docs.

cc @radoering

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the prerelease calculation is wrong, running the version command can write an incorrect version into the project configuration; reverting the code does not restore that value, though it can be corrected manually. The impact is bounded to projects that use the command and can be repaired before publishing.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@chinmayajha

Copy link
Copy Markdown
Contributor Author

@radoering @Secrus would one of you have time to review this? CI is green.

@radoering
radoering force-pushed the version-prerelease-dev branch from a6b33ae to a84edc6 Compare November 15, 2026 06:40
@radoering radoering added impact/docs Contains or requires documentation changes and removed impact/docs Contains or requires documentation changes labels Nov 15, 2026
@radoering
radoering merged commit 18668c8 into python-poetry:main Nov 15, 2026
102 of 105 checks passed
@chinmayajha
chinmayajha deleted the version-prerelease-dev branch November 15, 2026 18:31
radoering pushed a commit that referenced this pull request Nov 21, 2026
mwalbeck pushed a commit to mwalbeck/docker-python-poetry that referenced this pull request Nov 28, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [poetry](https://github.com/python-poetry/poetry) ([changelog](https://python-poetry.org/history/)) | patch | `2.5.1` → `2.5.2` |

---

### Release Notes

<details>
<summary>python-poetry/poetry (poetry)</summary>

### [`v2.5.2`](https://github.com/python-poetry/poetry/blob/HEAD/CHANGELOG.md#252---2026-11-21)

[Compare Source](python-poetry/poetry@2.5.1...2.5.2)

##### Changed

- Allow `pkginfo>=2.0` ([#&#8203;11239](python-poetry/poetry#11239)).
- Report a comprehensible error if a configured repository is missing a URL ([#&#8203;11081](python-poetry/poetry#11081),
  [#&#8203;11114](python-poetry/poetry#11114),
  [#&#8203;11242](python-poetry/poetry#11242)).
- Report a comprehensible error for an invalid `--priority` in `poetry source add` instead of failing with a `KeyError` ([#&#8203;11175](python-poetry/poetry#11175)).

##### Fixed

- Fix an issue where `poetry install` built an sdist before checking it against its lock file hash ([#&#8203;11253](python-poetry/poetry#11253)).
- Fix an issue where `poetry install` rejected a distribution even though one of the hashes provided by the package index matched the hash locked for that file. ([#&#8203;11131](python-poetry/poetry#11131)).
- Fix an issue where uninstalling a path dependency failed if its source did not exist anymore ([#&#8203;11093](python-poetry/poetry#11093)).
- Fix an issue where `poetry version prerelease` failed for a dev release ([#&#8203;11217](python-poetry/poetry#11217)).

##### Docs

- Document the options of `poetry debug resolve` ([#&#8203;11211](python-poetry/poetry#11211)).
- Clarify `solver.min-release-age-exclude` and `solver.min-release-age-exclude-source` ([#&#8203;11087](python-poetry/poetry#11087)).
- Distinguish package and upload repository URLs ([#&#8203;11143](python-poetry/poetry#11143)).
- Explain the certificate configuration for system Git ([#&#8203;11145](python-poetry/poetry#11145)).
- Add separate directory and archive path dependency examples ([#&#8203;11079](python-poetry/poetry#11079)).
- Use the plugin repository for the `poetry-export` pre-commit hook ([#&#8203;11213](python-poetry/poetry#11213)).
- Fix the incorrect `tool.poetry` section name in the FAQ ([#&#8203;11150](python-poetry/poetry#11150)).

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI2MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.walbeck.it/mwalbeck/docker-python-poetry/pulls/1778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants