MCPcopy
hub / github.com/pytest-dev/pytest / getargs

Method getargs

src/_pytest/_code/code.py:113–129  ·  view source on GitHub ↗

Return a tuple with the argument names for the code object. If 'var' is set True also return the names of the variable and keyword arguments when present.

(self, var: bool = False)

Source from the content-addressed store, hash-verified

111 return Source(self.raw)
112
113 def getargs(self, var: bool = False) -> tuple[str, ...]:
114 """Return a tuple with the argument names for the code object.
115
116 If 'var' is set True also return the names of the variable and
117 keyword arguments when present.
118 """
119 # inspect.getargs merges positional and kwonly into a single list;
120 # co_argcount is needed to exclude kwonly when var=False.
121 args, varargs, varkw = inspect.getargs(self.raw)
122 if not var:
123 return tuple(args[: self.raw.co_argcount])
124 result = list(args)
125 if varargs is not None:
126 result.append(varargs)
127 if varkw is not None:
128 result.append(varkw)
129 return tuple(result)
130
131
132class Frame:

Callers 3

getargsMethod · 0.45
repr_argsMethod · 0.45
test_code_getargsFunction · 0.45

Calls 1

appendMethod · 0.80

Tested by 1

test_code_getargsFunction · 0.36