Summary
https://play.ty.dev/95eb2f4a-476f-40c7-8ea9-6fa12b4d3d15
https://play.ty.dev/5a5b21ac-73b4-4b9a-b3ac-f12029b064ca
The only difference between these two links is that the TypeVar bound changes from A to A | C.
I won't claim to understand python typing semantics and rules well (does anyone?) but I can't see how this makes any sense. Adding a union to a bound should only increase the number of acceptable matches, I can't see how it would make sense to have it invalidate an otherwise valid option.
The full error message given by ty check is
info: `list` is invariant in its type parameter
info: Consider using the covariant supertype `collections.abc.Sequence`
info: For more information, see https://docs.astral.sh/ty/reference/typing-faq/#invariant-generics
info: rule `invalid-argument-type` is enabled by default
which is why I wrote in the title that the covariant status of the typevar seems to be "lost" . . ty is telling me that the list is invariant regardless.
T_co = TypeVar("T_co", A , C, covariant=True) also does not work.
Version
ty 0.0.28
Summary
https://play.ty.dev/95eb2f4a-476f-40c7-8ea9-6fa12b4d3d15
https://play.ty.dev/5a5b21ac-73b4-4b9a-b3ac-f12029b064ca
The only difference between these two links is that the TypeVar bound changes from A to A | C.
I won't claim to understand python typing semantics and rules well (does anyone?) but I can't see how this makes any sense. Adding a union to a bound should only increase the number of acceptable matches, I can't see how it would make sense to have it invalidate an otherwise valid option.
The full error message given by ty check is
which is why I wrote in the title that the covariant status of the typevar seems to be "lost" . . ty is telling me that the list is invariant regardless.
T_co = TypeVar("T_co", A , C, covariant=True)also does not work.Version
ty 0.0.28