thinc, the lower-level machine learning library used by spaCy took a related idea a little farther: https://github.com/explosion/thinc/blob/develop/thinc/types.py (they drop checks on specific dimension sizes/dtypes as far as I can tell, but use separate types for different dimension counts)
Do you want “any type” or do you want “any type with these characteristics”?
bound support Protocol?
T = TypeVar("T") class TypeClassEq(Protocol[T]): def __eq__(self: T, other: T) -> bool: ... TEq = TypeVar("TEq", bound=TypeClassEq)
If so, then
bound could be used to mimic constraints by type-classes.
retry_asyncand the related inner functions of the wrap
async deffor both
tmp.py:29: error: Incompatible return value type (got "Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]", expected "Callable[..., Awaitable[Any]]")with this gist https://gist.github.com/Callek/8bca70ffbe560c22dba72b21ecd49ec8