@@ -54,13 +54,13 @@ def update_version_in_file(file_path: Path, old_version: str, new_version: str)
5454 return False
5555
5656 content = file_path .read_text ()
57-
57+
5858 # Fix: Use re.sub with a function to avoid group reference issues
5959 pattern = rf'^(__version__\s*=\s*["\'])({ re .escape (old_version )} )(["\'])'
60-
60+
6161 def replacer (match ):
6262 return f"{ match .group (1 )} { new_version } { match .group (3 )} "
63-
63+
6464 new_content = re .sub (pattern , replacer , content , flags = re .MULTILINE )
6565
6666 if new_content != content :
@@ -74,17 +74,17 @@ def update_all_versions(old_version: str, new_version: str):
7474 # Update pyproject.toml - use simple string replacement to avoid regex issues
7575 pyproject = Path ("pyproject.toml" )
7676 content = pyproject .read_text ()
77-
77+
7878 # Simple string replacement instead of regex
7979 old_version_line = f'version = "{ old_version } "'
8080 new_version_line = f'version = "{ new_version } "'
81-
81+
8282 if old_version_line in content :
8383 content = content .replace (old_version_line , new_version_line , 1 )
8484 pyproject .write_text (content )
8585 print ("✓ Updated pyproject.toml" )
8686 else :
87- raise ValueError (f" Could not find version = \ "{ old_version } \ " in pyproject.toml" )
87+ raise ValueError (f' Could not find version = "{ old_version } " in pyproject.toml' )
8888
8989 # Update __init__.py files that contain version
9090 init_file = Path ("src/bedrock_agentcore/__init__.py" )
@@ -96,43 +96,43 @@ def format_git_log(git_log: str) -> str:
9696 """Format git log entries for changelog."""
9797 if not git_log .strip ():
9898 return ""
99-
99+
100100 fixes = []
101101 features = []
102102 docs = []
103103 other = []
104-
105- for line in git_log .strip ().split (' \n ' ):
104+
105+ for line in git_log .strip ().split (" \n " ):
106106 line = line .strip ()
107- if not line or not line .startswith ('-' ):
107+ if not line or not line .startswith ("-" ):
108108 continue
109-
109+
110110 commit_msg = line [2 :].strip ()
111-
112- if commit_msg .startswith (' fix:' ) or commit_msg .startswith (' bugfix:' ):
111+
112+ if commit_msg .startswith (" fix:" ) or commit_msg .startswith (" bugfix:" ):
113113 fixes .append (commit_msg )
114- elif commit_msg .startswith (' feat:' ) or commit_msg .startswith (' feature:' ):
114+ elif commit_msg .startswith (" feat:" ) or commit_msg .startswith (" feature:" ):
115115 features .append (commit_msg )
116- elif commit_msg .startswith (' docs:' ) or commit_msg .startswith (' doc:' ):
116+ elif commit_msg .startswith (" docs:" ) or commit_msg .startswith (" doc:" ):
117117 docs .append (commit_msg )
118118 else :
119119 other .append (commit_msg )
120-
120+
121121 sections = []
122-
122+
123123 if features :
124- sections .append ("### Added\n " + ' \n ' .join (f"- { msg } " for msg in features ))
125-
124+ sections .append ("### Added\n " + " \n " .join (f"- { msg } " for msg in features ))
125+
126126 if fixes :
127- sections .append ("### Fixed\n " + ' \n ' .join (f"- { msg } " for msg in fixes ))
128-
127+ sections .append ("### Fixed\n " + " \n " .join (f"- { msg } " for msg in fixes ))
128+
129129 if docs :
130- sections .append ("### Documentation\n " + ' \n ' .join (f"- { msg } " for msg in docs ))
131-
130+ sections .append ("### Documentation\n " + " \n " .join (f"- { msg } " for msg in docs ))
131+
132132 if other :
133- sections .append ("### Other Changes\n " + ' \n ' .join (f"- { msg } " for msg in other ))
134-
135- return ' \n \n ' .join (sections )
133+ sections .append ("### Other Changes\n " + " \n " .join (f"- { msg } " for msg in other ))
134+
135+ return " \n \n " .join (sections )
136136
137137
138138def get_git_log (since_tag : Optional [str ] = None ) -> str :
@@ -143,8 +143,7 @@ def get_git_log(since_tag: Optional[str] = None) -> str:
143143 else :
144144 try :
145145 last_tag = subprocess .run (
146- ["git" , "describe" , "--tags" , "--abbrev=0" ],
147- capture_output = True , text = True , check = True
146+ ["git" , "describe" , "--tags" , "--abbrev=0" ], capture_output = True , text = True , check = True
148147 ).stdout .strip ()
149148 cmd .append (f"{ last_tag } ..HEAD" )
150149 except subprocess .CalledProcessError :
@@ -172,7 +171,7 @@ def update_changelog(new_version: str, changes: str = None):
172171 else :
173172 print ("\n ⚠️ No changelog provided. Auto-generating from commits." )
174173 print ("💡 Tip: Use --changelog to provide meaningful release notes" )
175-
174+
176175 git_log = get_git_log ()
177176 if git_log :
178177 formatted_log = format_git_log (git_log )
@@ -229,4 +228,4 @@ def main():
229228
230229
231230if __name__ == "__main__" :
232- main ()
231+ main ()
0 commit comments