Forbid contravariant variable types, in addition to covariant variable types, in function signature #1190
Labels
bug
Something isn't working
fixed in next version (main)
A fix has been implemented and will appear in an upcoming version
Environment data
Sample code
Expected behavior
According to PEP 484 (https://www.python.org/dev/peps/pep-0484/#covariance-and-contravariance):
Covariant or contravariant type variables, used in functions, either in input or output, get marked as faulty.
Alternative expected behavior
Covariant type variables are allowed only in output but not input, while contravariant type variables are allowed only in input but not output.
In this ways, rule becomes consistent between functions and class methods.
Actual behavior
Covariant type variables are forbidden in input, but contravariant type variables are allowed in both input and output.
This behavior is the same as mypy, but I don't think it's right.
The text was updated successfully, but these errors were encountered: