MCPcopy
hub / github.com/pallets/click / MissingParameter

Class MissingParameter

src/click/exceptions.py:159–229  ·  view source on GitHub ↗

Raised if click required an option or argument but it was not provided when invoking the script. .. versionadded:: 4.0 :param param_type: a string that indicates the type of the parameter. The default is to inherit the parameter type from t

Source from the content-addressed store, hash-verified

157
158
159class MissingParameter(BadParameter):
160 """Raised if click required an option or argument but it was not
161 provided when invoking the script.
162
163 .. versionadded:: 4.0
164
165 :param param_type: a string that indicates the type of the parameter.
166 The default is to inherit the parameter type from
167 the given `param`. Valid values are ``'parameter'``,
168 ``'option'`` or ``'argument'``.
169 """
170
171 param_type: t.Final[str | None]
172
173 def __init__(
174 self,
175 message: str | None = None,
176 ctx: Context | None = None,
177 param: Parameter | None = None,
178 param_hint: cabc.Sequence[str] | str | None = None,
179 param_type: str | None = None,
180 ) -> None:
181 super().__init__(message or "", ctx, param, param_hint)
182 self.param_type = param_type
183
184 def format_message(self) -> str:
185 if self.param_hint is not None:
186 param_hint: cabc.Sequence[str] | str | None = self.param_hint
187 elif self.param is not None:
188 param_hint = self.param.get_error_hint(self.ctx)
189 else:
190 param_hint = None
191
192 param_hint = _join_param_hints(param_hint)
193 param_hint = f" {param_hint}" if param_hint else ""
194
195 param_type = self.param_type
196 if param_type is None and self.param is not None:
197 param_type = self.param.param_type_name
198
199 msg = self.message
200 if self.param is not None:
201 msg_extra = self.param.type.get_missing_message(
202 param=self.param, ctx=self.ctx
203 )
204 if msg_extra:
205 if msg:
206 msg += f". {msg_extra}"
207 else:
208 msg = msg_extra
209
210 msg = f" {msg}" if msg else ""
211
212 # Translate param_type for known types.
213 if param_type == "argument":
214 missing = _("Missing argument")
215 elif param_type == "option":
216 missing = _("Missing option")

Callers 1

process_valueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected