2121from __future__ import annotations
2222
2323import argparse
24+ import shutil
2425import subprocess
2526import sys
2627from pathlib import Path
@@ -51,13 +52,14 @@ def __init__(self) -> None:
5152 def _has_uv (self ) -> bool :
5253 """Check if uv is available."""
5354 try :
54- subprocess .run (["uv" , "--version" ], capture_output = True , check = True )
55- return True
55+ subprocess .run (["uv" , "--version" ], capture_output = True , check = True ) # noqa: S607
56+ return True # noqa: TRY300
5657 except (subprocess .CalledProcessError , FileNotFoundError ):
5758 return False
5859
5960 def _run_command (
6061 self ,
62+ * ,
6163 command : str ,
6264 description : str ,
6365 check : bool = True ,
@@ -77,18 +79,12 @@ def _run_command(
7779 capture_output = False ,
7880 )
7981 if result .returncode == 0 :
80- print (
81- f"{ Colors .GREEN } ✅ { description } completed successfully{ Colors .END } "
82- )
82+ print (f"{ Colors .GREEN } ✅ { description } completed successfully{ Colors .END } " )
8383 else :
84- print (
85- f"{ Colors .YELLOW } ⚠️ { description } completed with warnings{ Colors .END } "
86- )
87- return result
84+ print (f"{ Colors .YELLOW } ⚠️ { description } completed with warnings{ Colors .END } " )
85+ return result # noqa: TRY300
8886 except subprocess .CalledProcessError as e :
89- print (
90- f"{ Colors .RED } ❌ { description } failed with exit code { e .returncode } { Colors .END } "
91- )
87+ print (f"{ Colors .RED } ❌ { description } failed with exit code { e .returncode } { Colors .END } " )
9288 if check :
9389 raise
9490 return e
@@ -105,23 +101,19 @@ def setup(self) -> None:
105101
106102 # Install dependencies
107103 if self ._has_uv ():
108- self ._run_command ("uv sync --dev" , "Installing dependencies with uv" )
104+ self ._run_command (command = "uv sync --dev" , description = "Installing dependencies with uv" )
109105 else :
110- self ._run_command (
111- "pip install -e ." , "Installing project in development mode"
112- )
106+ self ._run_command (command = "pip install -e ." , description = "Installing project in development mode" )
113107
114108 # Setup pre-commit
115- self ._run_command (
116- f"{ self .python_cmd } pre-commit install" , "Installing pre-commit hooks"
117- )
109+ self ._run_command (command = f"{ self .python_cmd } pre-commit install" , description = "Installing pre-commit hooks" )
118110
119111 # Initialize secrets baseline
120112 secrets_baseline = self .root_dir / ".secrets.baseline"
121113 if not secrets_baseline .exists ():
122114 self ._run_command (
123- f"{ self .python_cmd } detect-secrets scan --baseline .secrets.baseline" ,
124- "Creating secrets detection baseline" ,
115+ command = f"{ self .python_cmd } detect-secrets scan --baseline .secrets.baseline" ,
116+ description = "Creating secrets detection baseline" ,
125117 )
126118
127119 # Create necessary directories
@@ -243,8 +235,6 @@ def clean(self) -> None:
243235 """Clean up temporary files."""
244236 self ._print_header ("Cleaning Temporary Files" )
245237
246- import shutil
247-
248238 cleanup_patterns = [
249239 "**/__pycache__" ,
250240 "**/*.pyc" ,
@@ -324,9 +314,7 @@ def update(self) -> None:
324314 self ._print_header ("Updating Dependencies" )
325315
326316 if self ._has_uv ():
327- self ._run_command (
328- "uv sync --dev --upgrade" , "Updating dependencies with uv"
329- )
317+ self ._run_command ("uv sync --dev --upgrade" , "Updating dependencies with uv" )
330318 else :
331319 self ._run_command ("pip install --upgrade -e .[dev]" , "Updating with pip" )
332320
@@ -338,9 +326,7 @@ def main() -> NoReturn:
338326 """Main entry point."""
339327 workflow = DevWorkflow ()
340328
341- parser = argparse .ArgumentParser (
342- description = "Development workflow automation for GenAI Python projects"
343- )
329+ parser = argparse .ArgumentParser (description = "Development workflow automation for GenAI Python projects" )
344330 parser .add_argument (
345331 "command" ,
346332 choices = [
0 commit comments