-
Hi, I'm trying to type-hint a Descriptor protocol, but encountering some issues with variance. In the following code snippet, the descriptor is type-hinted such that when it is accessed on an instance, it returns pyright (version 1.1.143) complains that the Is there an issue with my type-hinting? Is this an issue with pyright? I'm not sure how to understand or fix the issue. 1 - Invariant
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for the bug report. Your second example (where |
Beta Was this translation helpful? Give feedback.
Thanks for the bug report. Your second example (where
ValueType
is contravariant) should type check without errors. The check for a contravariant type variable used as a return type should ignore cases when it is part of a union. I've addressed the bug, and the fix will appear in the next release. In the meantime, you can use a# type: ignore
comment to suppress the errors.