MCPcopy Index your code
hub / github.com/python/mypy / add_args

Method add_args

mypy/stubgenc.py:317–336  ·  view source on GitHub ↗
(
            args: list[str], get_default_value: Callable[[int, str], object | _Missing]
        )

Source from the content-addressed store, hash-verified

315
316 # Add the arguments to the signature
317 def add_args(
318 args: list[str], get_default_value: Callable[[int, str], object | _Missing]
319 ) -> None:
320 for i, arg in enumerate(args):
321 # Check if the argument has a default value
322 default_value = get_default_value(i, arg)
323 if default_value is not _Missing.VALUE:
324 if arg in annotations:
325 argtype = get_annotation(arg)
326 else:
327 argtype = self.get_type_annotation(default_value)
328 if argtype == "None":
329 # None is not a useful annotation, but we can infer that the arg
330 # is optional
331 incomplete = self.add_name("_typeshed.Incomplete")
332 argtype = f"{incomplete} | None"
333
334 arglist.append(ArgSig(arg, argtype, default=True))
335 else:
336 arglist.append(ArgSig(arg, get_annotation(arg), default=False))
337
338 def get_pos_default(i: int, _arg: str) -> Any | _Missing:
339 if defaults and i >= len(args) - len(defaults):

Callers

nothing calls this directly

Calls 5

get_type_annotationMethod · 0.95
ArgSigClass · 0.90
enumerateFunction · 0.85
add_nameMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected