11#!/usr/bin/env python3
22"""Release management script for SignalRGB Python."""
33
4- # ruff: noqa: E501, T201
4+ # ruff: noqa: T201
55
66import os
77import re
88import shutil
99import subprocess
1010from subprocess import CompletedProcess
1111import sys
12+ import traceback
1213
1314from colorama import Style , init
1415from wcwidth import wcswidth
@@ -99,7 +100,10 @@ def strip_ansi(text: str) -> str:
99100
100101def apply_gradient (text : str , gradient : list [str ], line_number : int ) -> str :
101102 """Apply gradient colors diagonally to text."""
102- return "" .join (f"{ gradient [(i + line_number ) % len (gradient )]} { char } " for i , char in enumerate (text ))
103+ return "" .join (
104+ f"{ gradient [(i + line_number ) % len (gradient )]} { char } "
105+ for i , char in enumerate (text )
106+ )
103107
104108
105109def center_text (text : str , width : int ) -> str :
@@ -133,7 +137,9 @@ def create_banner() -> str:
133137 centered_logo = center_block (logo , content_width )
134138
135139 banner = [
136- center_text (f"{ COLOR_STAR } ・ 。 ☆ ∴。 ・゚*。★・ ∴。 ・゚*。☆ ・ 。 ☆ ∴。" , banner_width ),
140+ center_text (
141+ f"{ COLOR_STAR } ・ 。 ☆ ∴。 ・゚*。★・ ∴。 ・゚*。☆ ・ 。 ☆ ∴。" , banner_width
142+ ),
137143 f"{ COLOR_BORDER } ╭{ '─' * (banner_width - 2 )} ╮" ,
138144 ]
139145
@@ -150,7 +156,9 @@ def create_banner() -> str:
150156 f"{ COLOR_STAR } ∴。 ・゚*。☆ { release_manager_text } { COLOR_STAR } ☆。*゚・ 。∴" ,
151157 banner_width ,
152158 ),
153- center_text (f"{ COLOR_STAR } ・ 。 ☆ ∴。 ・゚*。★・ ∴。 ・゚*。☆ ・ 。 ☆ ∴。" , banner_width ),
159+ center_text (
160+ f"{ COLOR_STAR } ・ 。 ☆ ∴。 ・゚*。★・ ∴。 ・゚*。☆ ・ 。 ☆ ∴。" , banner_width
161+ ),
154162 ]
155163 )
156164
@@ -163,7 +171,10 @@ def print_logo() -> None:
163171
164172
165173def run_command (
166- cmd : list [str ], check : bool = False , capture_output : bool = False , text : bool = False
174+ cmd : list [str ],
175+ check : bool = False ,
176+ capture_output : bool = False ,
177+ text : bool = False ,
167178) -> CompletedProcess [str | bytes ]:
168179 """
169180 Run a command safely with proper error handling.
@@ -184,7 +195,9 @@ def run_command(
184195
185196 try :
186197 # We're validating the command exists and controlling the input, so this is safe
187- return subprocess .run (cmd , check = check , capture_output = capture_output , text = text ) # noqa: S603
198+ return subprocess .run ( # noqa: S603
199+ cmd , check = check , capture_output = capture_output , text = text
200+ )
188201 except subprocess .CalledProcessError as e :
189202 if check :
190203 print_error (f"Command failed: { ' ' .join (cmd )} " )
@@ -194,7 +207,10 @@ def run_command(
194207
195208
196209def run_git_command (
197- args : list [str ], check : bool = False , capture_output : bool = False , text : bool = False
210+ args : list [str ],
211+ check : bool = False ,
212+ capture_output : bool = False ,
213+ text : bool = False ,
198214) -> CompletedProcess [str | bytes ]:
199215 """
200216 Run a git command safely.
@@ -212,7 +228,10 @@ def run_git_command(
212228
213229
214230def run_uv_command (
215- args : list [str ], check : bool = False , capture_output : bool = False , text : bool = False
231+ args : list [str ],
232+ check : bool = False ,
233+ capture_output : bool = False ,
234+ text : bool = False ,
216235) -> CompletedProcess [str | bytes ]:
217236 """
218237 Run a uv command safely.
@@ -238,7 +257,9 @@ def check_tool_installed(tool_name: str) -> None:
238257
239258def check_branch () -> None :
240259 """Ensure we're on the main branch."""
241- result = run_git_command (["rev-parse" , "--abbrev-ref" , "HEAD" ], capture_output = True , text = True )
260+ result = run_git_command (
261+ ["rev-parse" , "--abbrev-ref" , "HEAD" ], capture_output = True , text = True
262+ )
242263 current_branch = result .stdout .strip ()
243264 if current_branch != "main" :
244265 print_error ("You must be on the main branch to release." )
@@ -249,7 +270,9 @@ def check_uncommitted_changes() -> None:
249270 """Check for uncommitted changes."""
250271 result = run_git_command (["diff-index" , "--quiet" , "HEAD" , "--" ], check = False )
251272 if result .returncode != 0 :
252- print_error ("You have uncommitted changes. Please commit or stash them before releasing." )
273+ print_error (
274+ "You have uncommitted changes. Please commit or stash them before releasing."
275+ )
253276 sys .exit (1 )
254277
255278
@@ -315,7 +338,9 @@ def replace_version(match: re.Match[str]) -> str:
315338 updated_content = version_pattern .sub (replace_version , content )
316339
317340 if content == updated_content :
318- print_warning (f"No version field found in { DOCS_INDEX } or version already up to date." )
341+ print_warning (
342+ f"No version field found in { DOCS_INDEX } or version already up to date."
343+ )
319344 return
320345
321346 with open (DOCS_INDEX , "w" , encoding = "utf-8" ) as f :
@@ -350,7 +375,9 @@ def commit_and_push(version: str) -> None:
350375 print_step ("Committing and pushing changes" )
351376 try :
352377 run_git_command (["add" , PYPROJECT_TOML , DOCS_INDEX , "uv.lock" ], check = True )
353- run_git_command (["commit" , "-m" , f":rocket: Release version { version } " ], check = True )
378+ run_git_command (
379+ ["commit" , "-m" , f":rocket: Release version { version } " ], check = True
380+ )
354381 run_git_command (["push" ], check = True )
355382 run_git_command (["tag" , f"v{ version } " ], check = True )
356383 run_git_command (["push" , "--tags" ], check = True )
@@ -383,7 +410,9 @@ def main() -> None:
383410 )
384411
385412 if not is_valid_version (new_version ):
386- print_error ("Invalid version format. Please use semantic versioning (e.g., 1.2.3)." )
413+ print_error (
414+ "Invalid version format. Please use semantic versioning (e.g., 1.2.3)."
415+ )
387416 sys .exit (1 )
388417
389418 update_version (new_version )
@@ -396,10 +425,11 @@ def main() -> None:
396425
397426 commit_and_push (new_version )
398427
399- print_success (f"\n 🎉✨ { PROJECT_NAME } v{ new_version } has been successfully released! ✨🎉" )
428+ print_success (
429+ f"\n 🎉✨ { PROJECT_NAME } v{ new_version } has been successfully released! ✨🎉"
430+ )
400431 except Exception as e : # noqa: BLE001
401432 print_error (f"An unexpected error occurred: { e } " )
402- import traceback
403433
404434 traceback .print_exc ()
405435 sys .exit (1 )
0 commit comments