MCPcopy Index your code
hub / github.com/python/cpython / Parameter

Class Parameter

Tools/clinic/libclinic/function.py:196–263  ·  view source on GitHub ↗

Mutable duck type of inspect.Parameter.

Source from the content-addressed store, hash-verified

194
195@dc.dataclass(repr=False, slots=True)
196class Parameter:
197 """
198 Mutable duck type of inspect.Parameter.
199 """
200 name: str
201 kind: inspect._ParameterKind
202 _: dc.KW_ONLY
203 default: object = inspect.Parameter.empty
204 function: Function
205 converter: CConverter
206 annotation: object = inspect.Parameter.empty
207 docstring: str = ''
208 group: int = 0
209 # (`None` signifies that there is no deprecation)
210 deprecated_positional: VersionTuple | None = None
211 deprecated_keyword: VersionTuple | None = None
212 right_bracket_count: int = dc.field(init=False, default=0)
213
214 def __repr__(self) -> str:
215 return f'<clinic.Parameter {self.name!r}>'
216
217 def is_keyword_only(self) -> bool:
218 return self.kind == inspect.Parameter.KEYWORD_ONLY
219
220 def is_positional_only(self) -> bool:
221 return self.kind == inspect.Parameter.POSITIONAL_ONLY
222
223 def is_positional_or_keyword(self) -> bool:
224 return self.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD
225
226 def is_vararg(self) -> bool:
227 return self.kind == inspect.Parameter.VAR_POSITIONAL
228
229 def is_var_keyword(self) -> bool:
230 return self.kind == inspect.Parameter.VAR_KEYWORD
231
232 def is_variable_length(self) -> bool:
233 return self.is_vararg() or self.is_var_keyword()
234
235 def is_optional(self) -> bool:
236 return not self.is_vararg() and (self.default is not unspecified)
237
238 def copy(
239 self,
240 /,
241 *,
242 converter: CConverter | None = None,
243 function: Function | None = None,
244 **overrides: Any
245 ) -> Parameter:
246 function = function or self.function
247 if not converter:
248 converter = copy.copy(self.converter)
249 converter.function = function
250 return dc.replace(self, **overrides, function=function, converter=converter)
251
252 def get_displayname(self, i: int) -> str:
253 if i == 0:

Callers 3

add_functionMethod · 0.90
parse_parameterMethod · 0.90

Calls 1

fieldMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…