88from typing import (
99 TYPE_CHECKING ,
1010 Any ,
11+ ClassVar ,
1112 Literal ,
1213 NoReturn ,
1314 TypeVar ,
2728from .globals import pop_context , push_context
2829from .parser import _OptionParser
2930from .termui import style
30- from .types import ParamType
3131from .utils import echo , make_default_short_help
3232
3333if TYPE_CHECKING :
@@ -818,7 +818,6 @@ class Parameter(ABC):
818818 def __init__ (
819819 self ,
820820 param_decls : Sequence [str ] | None = None ,
821- type : ParamType | None = None ,
822821 required : bool = False ,
823822 default : Any | Callable [[], Any ] | None = None ,
824823 callback : Callable [[Context , "Parameter" , Any ], Any ] | None = None ,
@@ -839,15 +838,11 @@ def __init__(
839838 self .name , self .opts , self .secondary_opts = self ._parse_decls (
840839 param_decls or (), expose_value
841840 )
842- self .type = type if type is not None else ParamType ()
843841
844842 # Default nargs to what the type tells us if we have that
845843 # information available.
846844 if nargs is None :
847- if self .type .is_composite :
848- nargs = self .type .arity
849- else :
850- nargs = 1
845+ nargs = 1
851846
852847 self .required = required
853848 self .callback = callback
@@ -969,6 +964,18 @@ def resolve_envvar_value(self, ctx: Context) -> str | None:
969964
970965 return None
971966
967+ envvar_list_splitter : ClassVar [str | None ] = None
968+
969+ def split_envvar_value (self , rv : str ) -> Sequence [str ]:
970+ """Given a value from an environment variable this splits it up
971+ into small chunks depending on the defined envvar list splitter.
972+
973+ If the splitter is set to `None`, which means that whitespace splits,
974+ then leading and trailing whitespace is ignored. Otherwise, leading
975+ and trailing splitters usually lead to empty items being included.
976+ """
977+ return (rv or "" ).split (self .envvar_list_splitter )
978+
972979 def value_from_envvar (self , ctx : Context ) -> str | Sequence [str ] | None :
973980 """Process the value from the environment variable.
974981
@@ -978,7 +985,7 @@ def value_from_envvar(self, ctx: Context) -> str | Sequence[str] | None:
978985 rv : Any | None = self .resolve_envvar_value (ctx )
979986
980987 if rv is not None and (self .nargs != 1 or self .multiple ):
981- rv = self .type . split_envvar_value (rv )
988+ rv = self .split_envvar_value (rv )
982989
983990 return rv
984991
@@ -1031,7 +1038,6 @@ def get_error_hint(self, ctx: Context) -> str:
10311038 def shell_complete (self , ctx : Context , incomplete : str ) -> list ["CompletionItem" ]:
10321039 """Return a list of completions for the incomplete value. If a
10331040 ``shell_complete`` function was given during init, it is used.
1034- Otherwise, the `type` `ParamType.shell_complete` function is used.
10351041 """
10361042 if self ._custom_shell_complete is not None :
10371043 results = self ._custom_shell_complete (ctx , self , incomplete )
0 commit comments