(self, node: CallExpr)
| 289 | super().__init__() |
| 290 | |
| 291 | def visit_call_expr(self, node: CallExpr) -> str: |
| 292 | # Call expressions are not usually types, but we also treat `X = TypeVar(...)` as a |
| 293 | # type alias that has to be preserved (even if TypeVar is not the same as an alias) |
| 294 | callee = node.callee.accept(self) |
| 295 | args = [] |
| 296 | for name, arg, kind in zip(node.arg_names, node.args, node.arg_kinds): |
| 297 | if kind == ARG_POS: |
| 298 | args.append(arg.accept(self)) |
| 299 | elif kind == ARG_STAR: |
| 300 | args.append("*" + arg.accept(self)) |
| 301 | elif kind == ARG_STAR2: |
| 302 | args.append("**" + arg.accept(self)) |
| 303 | elif kind == ARG_NAMED: |
| 304 | args.append(f"{name}={arg.accept(self)}") |
| 305 | else: |
| 306 | raise ValueError(f"Unknown argument kind {kind} in call") |
| 307 | return f"{callee}({', '.join(args)})" |
| 308 | |
| 309 | def _visit_ref_expr(self, node: NameExpr | MemberExpr) -> str: |
| 310 | fullname = self.stubgen.get_fullname(node) |
nothing calls this directly
no test coverage detected