Skip to content

'Type parameter "T@Bar" is covariant, but "T@Bar" is not a subtype of "Jee"'. But T: Jee...? #8993

Answered by erictraut
qexat asked this question in Q&A
Discussion options

You must be logged in to vote

Pyright's behavior here is correct. (Not surprisingly, mypy generates the same error in this case.)

You haven't provided a type annotation for the self parameter in the bark method, so its type is implicitly typing.Self. If your intent is for it to be Jee, you can annotate it as such, but that means this method won't be callable for certain specializations of Bar. If you want bark to work with all parameterizations of Bar, then you'd need to change the return type of bark to Self.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@qexat
Comment options

Answer selected by qexat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants