@ethanhs Thanks! I actually considered that, but I wasn't sure if that was a weird pattern. Is there a standard for this / something people typically do? Or do people try to avoid being in this situation in the first place?
Also - I assume in that case I would need to write the typing as a string so it won't error at runtime? eg
input: "QueryInput" = etc as opposed to
input: QueryInput = etc
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