MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / validate_version

Function validate_version

scripts/prepare_release.py:94–115  ·  view source on GitHub ↗

Validate a release version string. Args: version: Version string without the leading tag prefix. Returns: The validated version string. Raises: ReleaseError: The version is empty, starts with `v`, or has an unsupported shape.

(version: str)

Source from the content-addressed store, hash-verified

92
93
94def validate_version(version: str) -> str:
95 """Validate a release version string.
96
97 Args:
98 version: Version string without the leading tag prefix.
99
100 Returns:
101 The validated version string.
102
103 Raises:
104 ReleaseError: The version is empty, starts with `v`, or has an unsupported
105 shape.
106 """
107 if version.startswith("v"):
108 raise ReleaseError(
109 "Pass the version without the tag prefix, for example 4.25.0"
110 )
111 if not VERSION_PATTERN.fullmatch(version):
112 raise ReleaseError(
113 "Unsupported version format. Expected a value like 4.25.0 or 4.26.0-beta.8"
114 )
115 return version
116
117
118def latest_tag() -> str:

Callers 1

mainFunction · 0.85

Calls 2

ReleaseErrorClass · 0.85
startswithMethod · 0.80

Tested by

no test coverage detected