Slice of `Union[...]` / `Optional[...]`, bare or `typing.`-prefixed. `Optional[X]`'s implicit `None` arm cannot encode a bare `Response`, so unwrapping `X` alone is enough.
(node: ast.expr)
| 451 | |
| 452 | |
| 453 | def _is_union_subscript(node: ast.expr) -> ast.expr | None: |
| 454 | """Slice of `Union[...]` / `Optional[...]`, bare or `typing.`-prefixed. |
| 455 | |
| 456 | `Optional[X]`'s implicit `None` arm cannot encode a bare `Response`, so |
| 457 | unwrapping `X` alone is enough.""" |
| 458 | if not isinstance(node, ast.Subscript): |
| 459 | return None |
| 460 | val = node.value |
| 461 | if isinstance(val, ast.Name) and val.id in _UNION_NAMES: |
| 462 | return node.slice |
| 463 | if isinstance(val, ast.Attribute) and val.attr in _UNION_NAMES: |
| 464 | return node.slice |
| 465 | return None |
| 466 | |
| 467 | |
| 468 | def _extract_response_annotation_Ts(returns: ast.expr | None) -> list[ast.expr] | None: |
no outgoing calls
no test coverage detected