Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to PEP 621 project.version before consulting SCM tags #306

Merged

Conversation

the-13th-letter
Copy link
Contributor

@the-13th-letter the-13th-letter commented Feb 23, 2025

  1. If tool.bumpversion.current_version is unset, but project.version from pyproject.toml is usable, then fall back to that value before attempting to consult Git/Mercurial/whatever tags.
  2. If project.version is set, and was used as the version source, then update that too, apart from tool.bumpversion.current_version.1
  3. Allow the sample configuration questionnaire to accept empty current_versions, indicating that project.version is to be used.

Closes #66.

Footnotes

  1. While I previously only wanted to update project.version if tool.bumpversion.current_version was unset, I now prefer always updating project.version no matter what. On the one hand, it avoids mismatched and stale metadata. On the other hand, my initial implementation already behaved this way, and I actually had trouble concocting a test case with the “only if used as the version source“ behavior that actually passes. (Perhaps some caching or staleness issue?) In any case, this variant is both simpler in code and probably less surprising to users.

@coordt
Copy link
Member

coordt commented Feb 24, 2025

I like the progress so far!

…ible

When determining the current version, and if
`tool.bumpversion.current_version` is not set, attempt to retrieve the
version from `project.version` à la PEP 621. If that setting is not
set, or if the version is explicitly marked as dynamically set, then
continue with querying SCM tags.

When updating the configuration during bumping, if we previously
successfully retrieved a PEP 621 version, then update the
`project.version` field in `pyproject.toml` as well. We always update,
even if the true current version was read from
`tool.bumpversion.current_version` instead of `project.version`.

The docs have been updated; specifically, the "multiple replacements in
one file" howto and the reference for `current_version`.

The tests have been adapted: the new `pep621_info` property would
otherwise trip up the old test output, and the `None` default would trip
up the TOML serializer. Additionally, new tests assert that
`project.version` (and correspondingly, the `pep621_info` property) is
correctly honored or ignored, depending on the other circumstances.
If the current version is explicitly left empty during the
`sample-config` questionnaire, the resulting `tool.bumpversion` table
now lacks a `current_version` key, and will fall back to PEP 621
`project.version` (if not dynamic). The instruction text specifically
hints at this new functionality.
@the-13th-letter the-13th-letter marked this pull request as ready for review February 27, 2025 13:30
@the-13th-letter
Copy link
Contributor Author

This is ready for review now. Code tests are included, and passing. Just about the only thing I'm still unsure of are the documentation changes and the commit message texts: I couldn't build the documentation because I couldn't yet figure out which set of plugins and stuff are needed, and for the commit messages I wonder if they will be included in full in the changelog, and if so, if/how much I should trim them down.

Copy link

codecov bot commented Mar 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (pep621-version@ccebdb6). Learn more about missing BASE report.

Additional details and impacted files
@@                Coverage Diff                @@
##             pep621-version     #306   +/-   ##
=================================================
  Coverage                  ?   93.83%           
=================================================
  Files                     ?       29           
  Lines                     ?     1948           
  Branches                  ?      204           
=================================================
  Hits                      ?     1828           
  Misses                    ?       91           
  Partials                  ?       29           
Flag Coverage Δ
python-3.10 93.83% <100.00%> (?)
python-3.11 93.83% <100.00%> (?)
python-3.12 93.83% <100.00%> (?)
python-3.13 93.83% <100.00%> (?)
python-3.8 93.83% <100.00%> (?)
python-3.9 93.83% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coordt coordt changed the base branch from master to pep621-version March 1, 2025 13:21
@coordt coordt merged commit abdefa0 into callowayproject:pep621-version Mar 1, 2025
16 of 20 checks passed
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.

Support PEP 621 version?
2 participants