99import  sys 
1010from  argparse  import  SUPPRESS , Action , ArgumentDefaultsHelpFormatter , ArgumentError , ArgumentParser , Namespace 
1111from  pathlib  import  Path 
12- from  typing  import  TYPE_CHECKING , Any , Callable , Dict , List , Literal , Optional , Sequence , Tuple , Type , TypeVar , cast 
12+ from  types  import  UnionType 
13+ from  typing  import  TYPE_CHECKING , Any , Literal , TypeVar , cast 
1314
1415from  colorama  import  Fore 
1516
2627    from  typing_extensions  import  Self 
2728
2829if  TYPE_CHECKING :
30+     from  collections .abc  import  Callable , Sequence 
31+ 
2932    from  tox .session .state  import  State 
3033
3134
@@ -64,7 +67,7 @@ def get_type(action: Action) -> type[Any]:
6467        of_type : type [Any ] |  None  =  getattr (action , "of_type" , None )
6568        if  of_type  is  None :
6669            if  isinstance (action , argparse ._AppendAction ):  # noqa: SLF001 
67-                 of_type  =  List [action .type ]  # type: ignore[name-defined] 
70+                 of_type  =  list [action .type ]  # type: ignore[name-defined] 
6871            elif  isinstance (action , argparse ._StoreAction ) and  action .choices :  # noqa: SLF001 
6972                loc  =  locals ()
7073                loc ["Literal" ] =  Literal 
@@ -135,7 +138,7 @@ def is_colored(self) -> bool:
135138    exit_and_dump_after : int 
136139
137140
138- ArgumentArgs  =  Tuple [ Tuple [str , ...], Optional [ Type [ Any ]],  Dict [str , Any ]]
141+ ArgumentArgs  =  tuple [ tuple [str , ...], type [ Any ]  |   UnionType   |   None ,  dict [str , Any ]]
139142
140143
141144class  ToxParser (ArgumentParserWithEnvAndConfig ):
@@ -230,7 +233,7 @@ def __call__(
230233            help = "set PYTHONHASHSEED to SEED before running commands. Defaults to a random integer in the range " 
231234            "[1, 4294967295] ([1, 1024] on Windows). Passing 'notset' suppresses this behavior." ,
232235            action = SeedAction ,
233-             of_type = Optional [ int ],   # type: ignore[arg-type] 
236+             of_type = int   |   None , 
234237            default = hashseed_default ,
235238            dest = "hash_seed" ,
236239        )
@@ -239,7 +242,7 @@ def __call__(
239242            dest = "discover" ,
240243            nargs = "+" ,
241244            metavar = "path" ,
242-             of_type = List [str ],
245+             of_type = list [str ],
243246            help = "for Python discovery first try these Python executables" ,
244247            default = [],
245248        )
@@ -280,7 +283,7 @@ def add_argument(*a_args: str, of_type: type[Any] | None = None, **a_kwargs: Any
280283            self ._groups .append ((args , kwargs , excl ))
281284        return  result 
282285
283-     def  add_argument (self , * args : str , of_type : type [Any ] |  None  =  None , ** kwargs : Any ) ->  Action :
286+     def  add_argument (self , * args : str , of_type : type [Any ] |  UnionType   |   None  =  None , ** kwargs : Any ) ->  Action :
284287        result  =  super ().add_argument (* args , ** kwargs )
285288        if  self .of_cmd  is  None  and  result .dest  !=  "help" :
286289            self ._arguments .append ((args , of_type , kwargs ))
@@ -403,7 +406,7 @@ def add_core_arguments(parser: ArgumentParser) -> None:
403406        metavar = "file" ,
404407        default = None ,
405408        type = Path ,
406-         of_type = Optional [ Path ] ,
409+         of_type = Path   |   None ,
407410        help = "configuration file/folder for tox (if not specified will discover one)" ,
408411    )
409412    parser .add_argument (
@@ -412,7 +415,7 @@ def add_core_arguments(parser: ArgumentParser) -> None:
412415        metavar = "dir" ,
413416        default = None ,
414417        type = Path ,
415-         of_type = Optional [ Path ] ,
418+         of_type = Path   |   None ,
416419        help = "tox working directory (if not specified will be the folder of the config file)" ,
417420    )
418421    parser .add_argument (
@@ -421,7 +424,7 @@ def add_core_arguments(parser: ArgumentParser) -> None:
421424        metavar = "dir" ,
422425        default = None ,
423426        type = Path ,
424-         of_type = Optional [ Path ] ,
427+         of_type = Path   |   None ,
425428        help = "project root directory (if not specified will be the folder of the config file)" ,
426429    )
427430
0 commit comments