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)
| 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 | |
| 132 | class Frame: |