1- import collections .abc as cabc
21import enum
32import inspect
43import os
54from abc import ABC , abstractmethod
6- from collections .abc import Callable
5+ from collections .abc import Callable , Iterator , Mapping , MutableMapping , Sequence
76from contextlib import AbstractContextManager , ExitStack , contextmanager
87from types import TracebackType
98from typing import (
4544
4645def _complete_visible_commands (
4746 ctx : "Context" , incomplete : str
48- ) -> cabc . Iterator [tuple [str , "Command" ]]:
47+ ) -> Iterator [tuple [str , "Command" ]]:
4948 """List all the subcommands of a group that start with the
5049 incomplete value and aren't hidden.
5150 """
@@ -65,7 +64,7 @@ def _complete_visible_commands(
6564@contextmanager
6665def augment_usage_errors (
6766 ctx : "Context" , param : Union ["Parameter" , None ] = None
68- ) -> cabc . Iterator [None ]:
67+ ) -> Iterator [None ]:
6968 """Context manager that attaches extra information to exceptions."""
7069 try :
7170 yield
@@ -82,8 +81,8 @@ def augment_usage_errors(
8281
8382
8483def iter_params_for_processing (
85- invocation_order : cabc . Sequence ["Parameter" ],
86- declaration_order : cabc . Sequence ["Parameter" ],
84+ invocation_order : Sequence ["Parameter" ],
85+ declaration_order : Sequence ["Parameter" ],
8786) -> list ["Parameter" ]:
8887 """Returns all declared parameters in the order they should be processed.
8988
@@ -147,7 +146,7 @@ def __init__(
147146 info_name : str | None = None ,
148147 obj : Any | None = None ,
149148 auto_envvar_prefix : str | None = None ,
150- default_map : cabc . MutableMapping [str , Any ] | None = None ,
149+ default_map : MutableMapping [str , Any ] | None = None ,
151150 terminal_width : int | None = None ,
152151 max_content_width : int | None = None ,
153152 resilient_parsing : bool = False ,
@@ -186,7 +185,7 @@ def __init__(
186185 ):
187186 default_map = parent .default_map .get (info_name )
188187
189- self .default_map : cabc . MutableMapping [str , Any ] | None = default_map
188+ self .default_map : MutableMapping [str , Any ] | None = default_map
190189
191190 # This flag indicates if a subcommand is going to be executed.
192191 self .invoked_subcommand : str | None = None
@@ -291,7 +290,7 @@ def __exit__(
291290 return exit_result
292291
293292 @contextmanager
294- def scope (self , cleanup : bool = True ) -> cabc . Iterator ["Context" ]:
293+ def scope (self , cleanup : bool = True ) -> Iterator ["Context" ]:
295294 """This helper method can be used with the context object to promote
296295 it to the current thread local (see `get_current_context`).
297296 The default behavior of this is to invoke the cleanup functions which
@@ -524,7 +523,7 @@ class Command(ABC):
524523 def __init__ (
525524 self ,
526525 name : str | None ,
527- context_settings : cabc . MutableMapping [str , Any ] | None = None ,
526+ context_settings : MutableMapping [str , Any ] | None = None ,
528527 callback : Callable [..., Any ] | None = None ,
529528 params : list ["Parameter" ] | None = None ,
530529 help : str | None = None ,
@@ -541,7 +540,7 @@ def __init__(
541540 if context_settings is None :
542541 context_settings = {}
543542
544- self .context_settings : cabc . MutableMapping [str , Any ] = context_settings
543+ self .context_settings : MutableMapping [str , Any ] = context_settings
545544
546545 self .callback = callback
547546 self .params : list [Parameter ] = params or []
@@ -788,7 +787,7 @@ def shell_complete(self, ctx: Context, incomplete: str) -> list["CompletionItem"
788787 @abstractmethod
789788 def main (
790789 self ,
791- args : cabc . Sequence [str ] | None = None ,
790+ args : Sequence [str ] | None = None ,
792791 prog_name : str | None = None ,
793792 complete_var : str | None = None ,
794793 standalone_mode : bool = True ,
@@ -800,7 +799,7 @@ def main(
800799 @abstractmethod
801800 def _main_shell_completion (
802801 self ,
803- ctx_args : cabc . MutableMapping [str , Any ],
802+ ctx_args : MutableMapping [str , Any ],
804803 prog_name : str ,
805804 complete_var : str | None = None ,
806805 ) -> None :
@@ -824,7 +823,7 @@ class Parameter(ABC):
824823
825824 def __init__ (
826825 self ,
827- param_decls : cabc . Sequence [str ] | None = None ,
826+ param_decls : Sequence [str ] | None = None ,
828827 type : types .ParamType | Any | None = None ,
829828 required : bool = False ,
830829 default : Any | Callable [[], Any ] | None = None ,
@@ -834,7 +833,7 @@ def __init__(
834833 metavar : str | None = None ,
835834 expose_value : bool = True ,
836835 is_eager : bool = False ,
837- envvar : str | cabc . Sequence [str ] | None = None ,
836+ envvar : str | Sequence [str ] | None = None ,
838837 shell_complete : Callable [
839838 [Context , "Parameter" , str ], list ["CompletionItem" ] | list [str ]
840839 ]
@@ -872,7 +871,7 @@ def __repr__(self) -> str:
872871
873872 @abstractmethod
874873 def _parse_decls (
875- self , decls : cabc . Sequence [str ], expose_value : bool
874+ self , decls : Sequence [str ], expose_value : bool
876875 ) -> tuple [str | None , list [str ], list [str ]]:
877876 pass # pragma: no cover
878877
@@ -924,7 +923,7 @@ def add_to_parser(self, parser: _OptionParser, ctx: Context) -> None:
924923 pass # pragma: no cover
925924
926925 def consume_value (
927- self , ctx : Context , opts : cabc . Mapping [str , Any ]
926+ self , ctx : Context , opts : Mapping [str , Any ]
928927 ) -> tuple [Any , ParameterSource ]:
929928 value = opts .get (self .name ) # type: ignore
930929 source = ParameterSource .COMMANDLINE
@@ -950,7 +949,7 @@ def type_cast_value(self, ctx: Context, value: Any) -> Any:
950949 if value is None :
951950 return () if self .multiple or self .nargs == - 1 else None
952951
953- def check_iter (value : Any ) -> cabc . Iterator [Any ]:
952+ def check_iter (value : Any ) -> Iterator [Any ]:
954953 assert not isinstance (value , str )
955954 return iter (value )
956955
@@ -1037,7 +1036,7 @@ def resolve_envvar_value(self, ctx: Context) -> str | None:
10371036
10381037 return None
10391038
1040- def value_from_envvar (self , ctx : Context ) -> str | cabc . Sequence [str ] | None :
1039+ def value_from_envvar (self , ctx : Context ) -> str | Sequence [str ] | None :
10411040 """Process the raw environment variable string for this parameter.
10421041
10431042 Returns the string as-is or splits it into a sequence of strings if the
@@ -1052,7 +1051,7 @@ def value_from_envvar(self, ctx: Context) -> str | cabc.Sequence[str] | None:
10521051 return rv
10531052
10541053 def handle_parse_result (
1055- self , ctx : Context , opts : cabc . Mapping [str , Any ], args : list [str ]
1054+ self , ctx : Context , opts : Mapping [str , Any ], args : list [str ]
10561055 ) -> tuple [Any , list [str ]]:
10571056 """Process the value produced by the parser from user input.
10581057
0 commit comments