style: Improve code formatting and readability in update_version.py
This commit is contained in:
parent
5dfb96874e
commit
c9353cf8ea
1 changed files with 6 additions and 11 deletions
|
|
@ -27,11 +27,13 @@ def validate_version(version: str) -> bool:
|
|||
Returns:
|
||||
True if valid, False otherwise
|
||||
"""
|
||||
pattern = r'^\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?$'
|
||||
pattern = r"^\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?$"
|
||||
return bool(re.match(pattern, version))
|
||||
|
||||
|
||||
def update_file(file_path: Path, old_pattern: str, new_version: str, multiline: bool = False) -> bool:
|
||||
def update_file(
|
||||
file_path: Path, old_pattern: str, new_version: str, multiline: bool = False
|
||||
) -> bool:
|
||||
"""Update version in a file.
|
||||
|
||||
Args:
|
||||
|
|
@ -94,10 +96,7 @@ def main() -> int:
|
|||
# Use word boundary to match 'version' but not 'python_version'
|
||||
pattern = r'^version = "[^"]+"'
|
||||
success &= update_file(
|
||||
pyproject_path,
|
||||
pattern,
|
||||
f'version = "{new_version}"',
|
||||
multiline=True
|
||||
pyproject_path, pattern, f'version = "{new_version}"', multiline=True
|
||||
)
|
||||
else:
|
||||
print(f"✗ {pyproject_path} not found")
|
||||
|
|
@ -106,11 +105,7 @@ def main() -> int:
|
|||
# Update __init__.py
|
||||
if init_path.exists():
|
||||
pattern = r'__version__ = "[^"]+"'
|
||||
success &= update_file(
|
||||
init_path,
|
||||
pattern,
|
||||
f'__version__ = "{new_version}"'
|
||||
)
|
||||
success &= update_file(init_path, pattern, f'__version__ = "{new_version}"')
|
||||
else:
|
||||
print(f"✗ {init_path} not found")
|
||||
success = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue