Summary
Given this line https://github.com/litestar-org/type-lens/blob/main/type_lens/type_view.py#L227 I think that could/should be rephrased as if isinstance(self.annotation, typ): return TypeView(Union[bytes, str]).is_subtype_of(typ). And that seems interesting.
Because it does feel like T = TypeVar(int, float); TypeVar(T).is_subtype_of(int) should return True, or that T = TypeVar(bound=Union[int, float]); TypeVar(T).is_union should return True.
Following from that, it feels like either TypeView should either transparently be doing something equivalent to the following:
if isinstance(annotation, TypeVar):
bound = self.annotation.__bound__
if bound:
return TypeView(bound)
constraints = self.annotation.__constraints__
return TypeView(Union[*constraints])
or it should have a method like resolve_type_var which does this recursively (because e.g. list[T]) or something...
I suppose the contravariant/covariant kwargs for constraints are a meaningful consideration potentially...but i dunno...
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
Summary
Given this line https://github.com/litestar-org/type-lens/blob/main/type_lens/type_view.py#L227 I think that could/should be rephrased as
if isinstance(self.annotation, typ): return TypeView(Union[bytes, str]).is_subtype_of(typ). And that seems interesting.Because it does feel like
T = TypeVar(int, float); TypeVar(T).is_subtype_of(int)should return True, or thatT = TypeVar(bound=Union[int, float]); TypeVar(T).is_unionshould return True.Following from that, it feels like either
TypeViewshould either transparently be doing something equivalent to the following:or it should have a method like
resolve_type_varwhich does this recursively (because e.g.list[T]) or something...I suppose the contravariant/covariant kwargs for constraints are a meaningful consideration potentially...but i dunno...
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response