1 from typing import Any, Callable, IO, Iterable, List, Optional, TypeVar, Union, Tuple as _PyTuple, Type
\r
4 from click.core import Context, Parameter, _ParamType as ParamType, _ConvertibleType
\r
6 class BoolParamType(ParamType):
\r
9 value: Optional[str],
\r
10 param: Optional[Parameter] = ...,
\r
11 ctx: Optional[Context] = ...,
\r
18 param: Optional[Parameter],
\r
19 ctx: Optional[Context],
\r
24 class CompositeParamType(ParamType):
\r
28 class Choice(ParamType):
\r
29 choices: Iterable[str]
\r
30 def __init__(self, choices: Iterable[str]) -> None:
\r
34 class FloatParamType(ParamType):
\r
37 value: Optional[str],
\r
38 param: Optional[Parameter] = ...,
\r
39 ctx: Optional[Context] = ...,
\r
46 param: Optional[Parameter],
\r
47 ctx: Optional[Context],
\r
52 class FloatRange(FloatParamType):
\r
56 class File(ParamType):
\r
60 encoding: Optional[str] = ...,
\r
61 errors: Optional[str] = ...,
\r
62 lazy: Optional[bool] = ...,
\r
63 atomic: Optional[bool] = ...,
\r
69 value: Optional[str],
\r
70 param: Optional[Parameter] = ...,
\r
71 ctx: Optional[Context] = ...,
\r
78 param: Optional[Parameter],
\r
79 ctx: Optional[Context],
\r
83 def resolve_lazy_flag(self, value: str) -> bool:
\r
87 _F = TypeVar('_F') # result of the function
\r
88 _Func = Callable[[Optional[str]], _F]
\r
91 class FuncParamType(ParamType):
\r
94 def __init__(self, func: _Func) -> None:
\r
99 value: Optional[str],
\r
100 param: Optional[Parameter] = ...,
\r
101 ctx: Optional[Context] = ...,
\r
108 param: Optional[Parameter],
\r
109 ctx: Optional[Context],
\r
114 class IntParamType(ParamType):
\r
117 value: Optional[str],
\r
118 param: Optional[Parameter] = ...,
\r
119 ctx: Optional[Context] = ...,
\r
126 param: Optional[Parameter],
\r
127 ctx: Optional[Context],
\r
132 class IntRange(IntParamType):
\r
134 self, min: Optional[int] = ..., max: Optional[int] = ..., clamp: bool = ...
\r
139 _PathType = TypeVar('_PathType', str, bytes)
\r
142 class Path(ParamType):
\r
145 exists: bool = ...,
\r
146 file_okay: bool = ...,
\r
147 dir_okay: bool = ...,
\r
148 writable: bool = ...,
\r
149 readable: bool = ...,
\r
150 resolve_path: bool = ...,
\r
151 allow_dash: bool = ...,
\r
152 path_type: Optional[Type[_PathType]] = ...,
\r
156 def coerce_path_result(self, rv: Union[str, bytes]) -> _PathType:
\r
161 value: Optional[str],
\r
162 param: Optional[Parameter] = ...,
\r
163 ctx: Optional[Context] = ...,
\r
170 param: Optional[Parameter],
\r
171 ctx: Optional[Context],
\r
175 class StringParamType(ParamType):
\r
178 value: Optional[str],
\r
179 param: Optional[Parameter] = ...,
\r
180 ctx: Optional[Context] = ...,
\r
187 param: Optional[Parameter],
\r
188 ctx: Optional[Context],
\r
193 class Tuple(CompositeParamType):
\r
194 types: List[ParamType]
\r
196 def __init__(self, types: Iterable[Any]) -> None:
\r
201 value: Optional[str],
\r
202 param: Optional[Parameter] = ...,
\r
203 ctx: Optional[Context] = ...,
\r
210 param: Optional[Parameter],
\r
211 ctx: Optional[Context],
\r
216 class UnprocessedParamType(ParamType):
\r
220 class UUIDParameterType(ParamType):
\r
223 value: Optional[str],
\r
224 param: Optional[Parameter] = ...,
\r
225 ctx: Optional[Context] = ...,
\r
232 param: Optional[Parameter],
\r
233 ctx: Optional[Context],
\r
238 def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -> ParamType:
\r
241 # parameter type shortcuts
\r
243 BOOL = BoolParamType()
\r
244 FLOAT = FloatParamType()
\r
245 INT = IntParamType()
\r
246 STRING = StringParamType()
\r
247 UNPROCESSED = UnprocessedParamType()
\r
248 UUID = UUIDParameterType()
\r