Apologies for the completely unrealistic type definitions here. I was working from first principles, trying to come up with weird definitions that could break, not starting with real-world code. I tried to construct a more realistic example, but was not able to reproduce the issue.
Given the following recursive type alias:
Pyright seems to infer that
A
is contravariant with respect toT
.However, if we unroll the definition once, we can more clearly see that
T
should be invariant:Playground
Apologies for the completely unrealistic type definitions here. I was working from first principles, trying to come up with weird definitions that could break, not starting with real-world code. I tried to construct a more realistic example, but was not able to reproduce the issue.