1 2 3 4 5 6 7 8 9
from typing import TypeVar, Any, Union V = TypeVar("V", str, bytes) def check_v(x: Union[V, list[V]]) -> V: raise NotImplementedError() def foo(a: list[Any]): check_v(a)