Return a list in a format suitable for dump() that represents the arguments and the body of a function. The caller can then decorate the array with information specific to methods, global functions or anonymous functions.
(self, o: mypy.nodes.FuncItem)
| 68 | return dump_tagged(nodes, tag, self) |
| 69 | |
| 70 | def func_helper(self, o: mypy.nodes.FuncItem) -> list[object]: |
| 71 | """Return a list in a format suitable for dump() that represents the |
| 72 | arguments and the body of a function. The caller can then decorate the |
| 73 | array with information specific to methods, global functions or |
| 74 | anonymous functions. |
| 75 | """ |
| 76 | args: list[mypy.nodes.Var | tuple[str, list[mypy.nodes.Node]]] = [] |
| 77 | extra: list[tuple[str, list[mypy.nodes.Var]]] = [] |
| 78 | for arg in o.arguments: |
| 79 | kind: mypy.nodes.ArgKind = arg.kind |
| 80 | if kind.is_required(): |
| 81 | args.append(arg.variable) |
| 82 | elif kind.is_optional(): |
| 83 | assert arg.initializer is not None |
| 84 | args.append(("default", [arg.variable, arg.initializer])) |
| 85 | elif kind == mypy.nodes.ARG_STAR: |
| 86 | extra.append(("VarArg", [arg.variable])) |
| 87 | elif kind == mypy.nodes.ARG_STAR2: |
| 88 | extra.append(("DictVarArg", [arg.variable])) |
| 89 | a: list[Any] = [] |
| 90 | if o.type_args: |
| 91 | for p in o.type_args: |
| 92 | a.append(self.type_param(p)) |
| 93 | if args: |
| 94 | a.append(("Args", args)) |
| 95 | if o.type: |
| 96 | a.append(o.type) |
| 97 | if o.is_generator: |
| 98 | a.append("Generator") |
| 99 | a.extend(extra) |
| 100 | a.append(o.body) |
| 101 | return a |
| 102 | |
| 103 | # Top-level structures |
| 104 |
no test coverage detected