Skip to content

Specialized Generic typed class plus class inheritance #1085

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

You must be logged in to vote

You're trying to fit a square peg into a round hole. This isn't really a generic class, but you're trying to model it as such. Do you have the flexibility of redesigning the class, or are you stuck with an existing design? If you are stuck with an existing design, could you provide more details about why you think Klass should be generic? Is _T used in other places within the class?

FWIW, pyright evaluates the type of x as Klass[int], which is what I'd expect in this case. I don't understand why mypy evaluates it as SubKlass[str*].

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by abelcheung
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