-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve stubs for operator
#13800
base: main
Are you sure you want to change the base?
Improve stubs for operator
#13800
Conversation
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[float | Literal[0], float | Literal[0]], float | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[complex | Literal[0], complex | Literal[0]], complex | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[signedinteger[_32Bit] | Literal[0], signedinteger[_32Bit] | Literal[0]], signedinteger[_32Bit] | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[signedinteger[_64Bit] | Literal[0], signedinteger[_64Bit] | Literal[0]], signedinteger[_64Bit] | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[floating[_32Bit] | Literal[0], floating[_32Bit] | Literal[0]], floating[_32Bit] | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[float64 | Literal[0], float64 | Literal[0]], float64 | Literal[0]]" [arg-type]
+ python/pyspark/core/rdd.py:2159: error: Argument 2 to "fold" of "RDD" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[ndarray[Any, Any] | Literal[0], ndarray[Any, Any] | Literal[0]], ndarray[Any, Any] | Literal[0]]" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/export/shape_poly.py:770: error: Argument 1 to "reduce" has incompatible type "Callable[[SupportsMul[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[int, _DimExpr], int]" [arg-type]
sympy (https://github.com/sympy/sympy)
+ sympy/polys/matrices/dense.py:104: error: Argument 1 to "map" has incompatible type "Callable[[SupportsMul[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[R, Any], R]" [arg-type]
+ sympy/tensor/array/expressions/arrayexpr_derivatives.py:44: error: Argument 1 to "reduce" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[tuple[()], Any], tuple[()]]" [arg-type]
+ sympy/tensor/array/expressions/arrayexpr_derivatives.py:45: error: Argument 1 to "reduce" has incompatible type "Callable[[SupportsAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[tuple[()], Any], tuple[()]]" [arg-type]
|
This won't work if you |
This also doesn't cover the reflected cases, i.e. when And if that wasn't complicated enough: When |
operator.add
,operator.mul
with existing ProtocolSupportsAdd
,SupportsMul