(self, node: IndexExpr)
| 341 | return self._visit_literal_node(node) |
| 342 | |
| 343 | def visit_index_expr(self, node: IndexExpr) -> str: |
| 344 | base_fullname = self.stubgen.get_fullname(node.base) |
| 345 | if base_fullname == "typing.Union": |
| 346 | if isinstance(node.index, TupleExpr): |
| 347 | return " | ".join([item.accept(self) for item in node.index.items]) |
| 348 | return node.index.accept(self) |
| 349 | if base_fullname == "typing.Optional": |
| 350 | if isinstance(node.index, TupleExpr): |
| 351 | return self.stubgen.add_name("_typeshed.Incomplete") |
| 352 | return f"{node.index.accept(self)} | None" |
| 353 | base = node.base.accept(self) |
| 354 | index = node.index.accept(self) |
| 355 | if len(index) > 2 and index.startswith("(") and index.endswith(")"): |
| 356 | index = index[1:-1].rstrip(",") |
| 357 | return f"{base}[{index}]" |
| 358 | |
| 359 | def visit_tuple_expr(self, node: TupleExpr) -> str: |
| 360 | suffix = "," if len(node.items) == 1 else "" |
nothing calls this directly
no test coverage detected