Skip to content

feat: extend version_variables to replace vars with annotations #1443

Description

@JCHacking

Description

Python-semantic-release does not detect and update version variables in Python files when they include type annotations (type hints).

Version

  • python-semantic-release: 10.5.3

Desired workflow

  1. Create a Python file with a version variable that includes a type hint:
# src/my_package/__init__.py
__version__: str = "1.6.0"
  1. Configure version_variables in pyproject.toml:
[tool.semantic_release]
version_variables = [
  "src/my_package/__init__.py:__version__",
]
  1. Run semantic-release version

Desired behavior

The __version__ variable should be updated to the new version (e.g., "1.7.0")

Current behavior

The __version__ variable is NOT updated. Only version_toml entries are updated.

Workaround

Remove the type hint from the version variable:

__version__ = "1.6.0"  # without type hint

Activity

  1. added
    bugSomething isn't working properly
    triagewaiting for initial maintainer review
    on Apr 22, 2026
  2. added
    confirmedPrevent from becoming stale
    featureA new feature or a feature request
    and removed
    triagewaiting for initial maintainer review
    bugSomething isn't working properly
    on Apr 22, 2026
  3. codejedi365 commented on Apr 22, 2026

    @codejedi365
    Contributor

    Changing to a feature request as version with a type annotation behavior was not a considered use (not documented example or tested by maintainers).

  4. changed the title [-]version_variables configuration fails to update Python variables with type hints[/-] [+]feat: extend `version_variables` to replace vars with annotations[/+] on Apr 23, 2026
  5. github-actions commented on Jul 22, 2026

    @github-actions

    It has been 90 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?

  6. added a commit that references this issue on Aug 29, 2026
    0f4aea5
  7. codejedi365 commented on Sep 22, 2026

    @codejedi365
    Contributor

    🎉 This issue has been resolved in v10.7.0 🎉

    You can find more information about this release on the GitHub Releases page.

    If your issue persists, please reply here and we will re-open the issue. If you receive a new error, please open a new issue and reference this issue there.

  8. added and removed
    confirmedPrevent from becoming stale
    needs-updateNeeds status update from maintainers
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new feature or a feature requestreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions