Skip to content

feat: extend version_variables to replace vars with annotations #1443

@JCHacking

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmedPrevent from becoming stalefeatureA new feature or a feature request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions