FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(config): support Python type-annotated version variables by Copilot · Pull Request #1485 · python-semantic-release/python-semantic-release · GitHub

feat(config): support Python type-annotated version variables - #1485

Merged
codejedi365 merged 3 commits into
masterfrom
copilot/fix-version-variable-detection
Aug 29, 2026
Merged

feat(config): support Python type-annotated version variables#1485
codejedi365 merged 3 commits into
masterfrom
copilot/fix-version-variable-detection

Conversation

Copilot AI commented Aug 29, 2026
edited by codejedi365
Loading

Copy link
Copy Markdown
Contributor

Version variables with PEP 526 type annotations (e.g., __version__: str = "1.0.0") were silently skipped during version stamping because the pattern regex had no support for the : <type> segment between variable name and assignment operator.

Changes

  • src/semantic_release/version/declarations/pattern.py: Insert an optional non-capturing regex group (?:\s*:\s*[^\s=:][^=:=]*)? between the variable name and assignment operator in from_string_definition. The character class [^\s=:] as the first character after the colon prevents matching := (walrus) or ::, preserving all existing operator handling.

  • tests/unit/semantic_release/version/declarations/test_pattern_declaration.py: Add four parametrized cases covering str, Optional[str], typing.Final[str] annotations, and tag-format with annotation.

Example

# Previously unmatched — now correctly stamped
__version__: str = "1.0.0"
__version__: Optional[str] = "1.0.0"
__version__: typing.Final[str] = "1.0.0"

# Existing patterns unaffected
__version__ = "1.0.0"          # plain assignment
if version := "1.0.0": ...     # walrus operator
newTag: v1.0.0                 # YAML colon separator

Fixes #1443

Copilot AI changed the title [WIP] Fix version variable detection for type annotated Python files feat(config): support Python type-annotated version variables Aug 29, 2026
Copilot AI requested a review from codejedi365 August 29, 2026 16:34
codejedi365 force-pushed the copilot/fix-version-variable-detection branch from 0f4aea5 to b41666e Compare August 29, 2026 18:52
codejedi365 marked this pull request as ready for review August 29, 2026 18:53
codejedi365 marked this pull request as draft August 29, 2026 18:53
codejedi365 assigned Copilot and unassigned codejedi365 and Copilot Aug 29, 2026
codejedi365 force-pushed the copilot/fix-version-variable-detection branch from b41666e to 01c8ce3 Compare August 29, 2026 18:59
codejedi365 marked this pull request as ready for review August 29, 2026 19:00
codejedi365 and others added 3 commits August 29, 2026 13:16
… variable

Signed-off-by: codejedi365 <codejedi365@users.noreply.github.com>
…on variables

Implements: #1443
Signed-off-by: codejedi365 <codejedi365@users.noreply.github.com>
…sion_variables`

Co-authored-by: codejedi365 <17354856+codejedi365@users.noreply.github.com>
Signed-off-by: codejedi365 <codejedi365@users.noreply.github.com>
codejedi365 force-pushed the copilot/fix-version-variable-detection branch from 4326a6f to f1a3d08 Compare August 29, 2026 19:17

codejedi365 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@copilot, can you make sure that the documentation is up to date to match this

codejedi365 merged commit 947c57b into master Aug 29, 2026
9 checks passed
codejedi365 deleted the copilot/fix-version-variable-detection branch August 29, 2026 19:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

feat: extend version_variables to replace vars with annotations

2 participants


Back | FazBrowse Home | New Git URL