44Usage: ./dev [command] [options] or ./dev for interactive mode
55"""
66
7+ from __future__ import annotations
8+
79import argparse
810import datetime
911import importlib .util
1416import subprocess
1517import sys
1618from pathlib import Path
17- from typing import Optional
1819
1920try :
2021 import questionary
@@ -99,7 +100,7 @@ def _run_command_with_confirmation(
99100
100101 return self ._run_command (cmd )
101102
102- def _run_command (self , cmd : list [str ], cwd : Optional [ Path ] = None ) -> bool :
103+ def _run_command (self , cmd : list [str ], cwd : Path | None = None ) -> bool :
103104 """Run a command and return True if successful."""
104105 try :
105106 self ._print_header (f"Running: { ' ' .join (cmd )} " )
@@ -178,10 +179,10 @@ def _find_files_to_clean(self) -> list[Path]:
178179
179180 def cmd_test (
180181 self ,
181- jobs : Optional [ int ] = None ,
182- filter_pattern : Optional [ str ] = None ,
182+ jobs : int | None = None ,
183+ filter_pattern : str | None = None ,
183184 skip_cleanup : bool = False ,
184- extra_args : Optional [ list [str ]] = None ,
185+ extra_args : list [str ] | None = None ,
185186 ) -> bool :
186187 """Run pytest with matplotlib comparison."""
187188 if jobs is None :
@@ -282,7 +283,7 @@ def cmd_baseline(self) -> bool:
282283
283284 return success
284285
285- def cmd_precommit (self , extra_args : Optional [ list [str ]] = None ) -> bool :
286+ def cmd_precommit (self , extra_args : list [str ] | None = None ) -> bool :
286287 """Run pre-commit hooks on all files."""
287288 self ._print_header ("Running Pre-commit Hooks" )
288289
@@ -351,7 +352,7 @@ def cmd_docs(
351352 port : int = 8000 ,
352353 clean : bool = True ,
353354 fast : bool = False ,
354- extra_args : Optional [ list [str ]] = None ,
355+ extra_args : list [str ] | None = None ,
355356 ) -> bool :
356357 """Build or serve documentation."""
357358 # Check if mkdocs is available
@@ -372,7 +373,7 @@ def cmd_docs(
372373 return False
373374
374375 def _build_docs (
375- self , clean : bool , fast : bool , extra_args : Optional [ list [str ]] = None
376+ self , clean : bool , fast : bool , extra_args : list [str ] | None = None
376377 ) -> bool :
377378 """Build documentation."""
378379 if fast :
@@ -411,7 +412,7 @@ def _build_docs(
411412 return success
412413
413414 def _serve_docs (
414- self , port : int , fast : bool , extra_args : Optional [ list [str ]] = None
415+ self , port : int , fast : bool , extra_args : list [str ] | None = None
415416 ) -> bool :
416417 """Serve documentation locally."""
417418 if fast :
@@ -489,8 +490,8 @@ def cmd_clean(self) -> bool:
489490 def cmd_benchmark (
490491 self ,
491492 action : str = "run" ,
492- baseline_name : Optional [ str ] = None ,
493- compare_with : Optional [ str ] = None ,
493+ baseline_name : str | None = None ,
494+ compare_with : str | None = None ,
494495 ) -> bool :
495496 """Run performance benchmarks."""
496497 # Check if pytest-benchmark is available
@@ -523,7 +524,7 @@ def _check_benchmark_available(self) -> bool:
523524 self ._print_warning ("Install with: pip install pytest-benchmark" )
524525 return False
525526
526- def _run_benchmarks (self , baseline_name : Optional [ str ] = None ) -> bool :
527+ def _run_benchmarks (self , baseline_name : str | None = None ) -> bool :
527528 """Run benchmark tests."""
528529 # Build benchmark command
529530 cmd = [
@@ -562,7 +563,7 @@ def _run_benchmarks(self, baseline_name: Optional[str] = None) -> bool:
562563
563564 return success
564565
565- def _compare_benchmarks (self , compare_with : Optional [ str ] = None ) -> bool :
566+ def _compare_benchmarks (self , compare_with : str | None = None ) -> bool :
566567 """Compare current benchmarks with a baseline."""
567568 benchmark_dir = self .project_root / "tests" / "baseline" / "benchmark"
568569
@@ -808,7 +809,7 @@ def _get_style(self):
808809
809810 def _get_text_input (
810811 self , prompt : str , default : str = "" , fallback_prompt : str = ""
811- ) -> Optional [ str ] :
812+ ) -> str | None :
812813 """Get text input with questionary or basic fallback."""
813814 if HAS_QUESTIONARY and questionary is not None :
814815 return questionary .text (prompt , default = default , style = self .style ).ask ()
@@ -823,7 +824,7 @@ def _get_text_input(
823824
824825 def _get_choice (
825826 self , prompt : str , choices : list [tuple ], fallback_prompt : str = ""
826- ) -> Optional [ str ] :
827+ ) -> str | None :
827828 """Get choice selection with questionary or basic fallback."""
828829 if HAS_QUESTIONARY and questionary is not None :
829830 choice_objects = [
0 commit comments