2525BUMP_TYPES = ["major" , "minor" , "patch" ]
2626
2727
28- def get_current_version ():
28+ def get_current_version () -> str :
2929 """Extract current version by importing the version module."""
3030 if str (SRC_DIR ) not in sys .path :
3131 sys .path .insert (0 , str (SRC_DIR ))
@@ -41,7 +41,7 @@ def get_current_version():
4141 sys .path .remove (str (SRC_DIR ))
4242
4343
44- def parse_version (version_string ) :
44+ def parse_version (version_string : str ) -> tuple [ int , int , int ] :
4545 """Parse version string, extracting major.minor.patch from PEP 440 format."""
4646 # Extract base version (major.minor.patch) from PEP 440 format
4747 # Examples: 1.2.3 -> (1,2,3), 1.2.3a1 -> (1,2,3), 1.2.3.dev1 -> (1,2,3)
@@ -56,13 +56,13 @@ def parse_version(version_string):
5656 raise ValueError (f"Invalid version format: { version_string } " ) from e
5757
5858
59- def validate_version_format (version_string ) :
59+ def validate_version_format (version_string : str ) -> None :
6060 """Validate that the version string follows PEP 440 format."""
6161 if not re .match (PEP440_PATTERN , version_string ):
6262 raise ValueError (f"Invalid version format (should follow PEP 440): { version_string } " )
6363
6464
65- def bump_version (current_version , bump_type ) :
65+ def bump_version (current_version : str , bump_type : str ) -> str :
6666 """Bump version based on type (major, minor, patch)."""
6767 major , minor , patch = parse_version (current_version )
6868
@@ -76,7 +76,7 @@ def bump_version(current_version, bump_type):
7676 raise ValueError (f"Invalid bump type: { bump_type } " )
7777
7878
79- def update_version (new_version ) :
79+ def update_version (new_version : str ) -> None :
8080 """Update version in _version.py and sync dependencies."""
8181 content = VERSION_FILE .read_text ()
8282 new_content = re .sub (r'__version__ = "[^"]+"' , f'__version__ = "{ new_version } "' , content )
@@ -89,7 +89,7 @@ def update_version(new_version):
8989 print (f"Warning: Failed to run 'uv sync': { e } " )
9090
9191
92- def handle_version_change (action_description , new_version ) :
92+ def handle_version_change (action_description : str , new_version : str ) -> str :
9393 """Handle version changes with common logic."""
9494 current = get_current_version ()
9595 print (f"{ action_description } from { current } to { new_version } " )
@@ -98,15 +98,15 @@ def handle_version_change(action_description, new_version):
9898 return new_version
9999
100100
101- def print_next_steps (version ) :
101+ def print_next_steps (version : str ) -> None :
102102 """Print the next steps after version update."""
103103 print ("\n Next steps:" )
104104 print (f"1. Commit the change: git add { FILES_TO_COMMIT } && git commit -m 'chore: bump version to { version } '" )
105105 print (f"2. Create and push tag: git tag v{ version } && git push origin v{ version } " )
106106 print ("3. The GitHub Action will automatically create a release and publish to PyPI and Container Registry" )
107107
108108
109- def main ():
109+ def main () -> None :
110110 """Handle version bumping operations."""
111111 if len (sys .argv ) not in [2 , 3 ]:
112112 print (__doc__ )
0 commit comments