2626from datetime import datetime , timedelta , timezone
2727from pathlib import Path
2828from subprocess import CompletedProcess
29- from typing import Any , Callable , NamedTuple , NoReturn , Optional
29+ from typing import Any , NamedTuple , NoReturn , TYPE_CHECKING
3030
3131import __main__
3232import rich .traceback
4040from tenacity .stop import stop_after_attempt , stop_after_delay
4141from tenacity .wait import wait_fixed
4242
43+ if TYPE_CHECKING :
44+ from collections .abc import Callable # pragma: no cover
45+
4346rich .traceback .install ()
4447
4548
@@ -142,7 +145,7 @@ def __init__(
142145 self ,
143146 stages : set [str ],
144147 * ,
145- console_force_terminal : Optional [ bool ] = None ,
148+ console_force_terminal : bool | None = None ,
146149 console_log_path : bool = True ,
147150 print_commands : bool = True ,
148151 ) -> None :
@@ -787,7 +790,7 @@ def run(
787790 command : str ,
788791 * ,
789792 pretty_print : bool = False ,
790- print_command : Optional [ bool ] = None ,
793+ print_command : bool | None = None ,
791794 ** kwargs : Any , # noqa: ANN401
792795 ) -> CompletedProcess :
793796 """
@@ -865,7 +868,7 @@ def pretty_print_command(self, command: str, indent: int = 4) -> str:
865868 #
866869
867870 def print_script_execution_summary (
868- self , extra_sections : Optional [ dict [str , str ]] = None
871+ self , extra_sections : dict [str , str ] | None = None
869872 ) -> None :
870873 """
871874 Print a summary of everything that was done by the script.
@@ -887,7 +890,7 @@ def print_script_execution_summary(
887890
888891 def print_script_execution_summary(
889892 self,
890- extra_sections: Optional[ dict[str, str]] = None
893+ extra_sections: dict[str, str] | None = None
891894 ) -> None:
892895 extras = {"Additional section": "With some details."}
893896 if extra_sections is not None:
0 commit comments