Skip to content

fix: handle VCS checkout CPython versions with trailing '+' in config - #579

Open
reginaldalfret wants to merge 1 commit into
Instagram:mainfrom
reginaldalfret:fix/vcs-python-version-trailing-plus
Open

reginaldalfret wants to merge 1 commit into
Instagram:mainfrom
reginaldalfret:fix/vcs-python-version-trailing-plus

Conversation

@reginaldalfret

Copy link
Copy Markdown

Summary

Fixes #576.

When running Fixit on a CPython interpreter built from a VCS branch/checkout rather than an official release tag, \platform.python_version()\ returns a version string with a trailing +\ (e.g. '3.13.15+').

In \merge_configs\ and the \Config.python_version\ default factory, initializing \Version(platform.python_version())\ fails with \packaging.version.InvalidVersion: Invalid version: '3.13.15+'\ because PEP 440 local versions require alphanumeric segments after +. This crashes \ ixit lint\ on every file when run on development Python builds.

Changes

  • Introduced \current_python_version()\ in \src/fixit/ftypes.py\ that strips any trailing '+'\ from \platform.python_version()\ before creating the \Version\ object.
  • Replaced direct \Version(platform.python_version())\ calls in \merge_configs\ (\src/fixit/config.py) and \Config\ default factory (\src/fixit/ftypes.py) with \current_python_version().
  • Added regression tests in \src/fixit/tests/config.py\ verifying that both \merge_configs\ and default \Config()\ instantiate correctly when \platform.python_version()\ returns a version with a trailing +\ (e.g. '3.13.15+').
  • Preserved strict configuration validation for user-defined \python-version\ entries.

Testing

  • Ran all 11 tests in \ ixit.tests.config\ including new regression tests:
    \
    Ran 11 tests in 0.642s - OK
    \\
  • Ran full test suite:
    \
    Ran 816 tests in 27.550s - OK
    \\
  • Verified code style and formatting with \ufmt check.

CPython builds from a VCS checkout append '+' to the version string (e.g.
'3.13.15+'). When running on such builds, packaging.version.Version rejects
the bare trailing '+' with an InvalidVersion exception, causing merge_configs
and default Config instantiation to fail on every file.

Introduce current_python_version() helper that strips any trailing '+' from
platform.python_version() before parsing as a Version, ensuring compatibility
with development builds while strictly preserving user configuration validation.

Closes Instagram#576

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

merge_configs crashes on a CPython built from a VCS checkout (platform.python_version() returns '3.13.15+')

1 participant