The list types among the members of a union.
(tp: Any)
| 8277 | |
| 8278 | |
| 8279 | def lists_in(tp: Any) -> list[Any]: |
| 8280 | """The list types among the members of a union.""" |
| 8281 | origin = get_origin(tp) |
| 8282 | if origin in (Annotated, Required, NotRequired): |
| 8283 | return lists_in(get_args(tp)[0]) |
| 8284 | if origin in (Union, UnionType): |
| 8285 | return [found for arg in get_args(tp) for found in lists_in(arg)] |
| 8286 | return [tp] if origin in (list, Iterable, Sequence) else [] |
| 8287 | |
| 8288 | |
| 8289 | def result_blocks(*unions: Any) -> list[Any]: |
no test coverage detected