-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Overhaul operator stubs
#6448
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
Overhaul operator stubs
#6448
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: pandera (https://github.com/pandera-dev/pandera)
+ pandera/strategies.py:565: error: Cannot call function of unknown type [operator]
+ pandera/checks.py:731: error: Cannot call function of unknown type [operator]
ibis (https://github.com/ibis-project/ibis)
+ ibis/backends/base/sql/registry/window.py:85: error: Cannot call function of unknown type
xarray (https://github.com/pydata/xarray)
+ xarray/core/accessor_str.py:2509: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[Iterable[Any], Iterable[Any]], Iterable[Any]]" [arg-type]
rotki (https://github.com/rotki/rotki)
+ rotkehlchen/chain/ethereum/modules/balancer/balancer.py:151: error: No overload variant of "map" matches argument types "function", "List[AssetAmount]", "List[AssetAmount]"
+ rotkehlchen/chain/ethereum/modules/balancer/balancer.py:151: note: Possible overload variant:
+ rotkehlchen/chain/ethereum/modules/balancer/balancer.py:151: note: def [_S, _T1, _T2] __init__(self, Callable[[_T1, _T2], _S], Iterable[_T1], Iterable[_T2]) -> map[_S]
+ rotkehlchen/chain/ethereum/modules/balancer/balancer.py:151: note: <5 more non-matching overloads not shown>
+ rotkehlchen/chain/ethereum/modules/balancer/balancer.py:154: error: Cannot call function of unknown type
+ tools/data_faker/data_faker/statistics.py:154: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function)
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/conversion.py:603: error: Argument 1 to "index" has incompatible type "float"; expected "SupportsIndex"
+ tanjun/conversion.py:654: error: Argument 1 to "index" has incompatible type "float"; expected "SupportsIndex"
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/computation/ops.py:413: error: Cannot call function of unknown type [operator]
+ pandas/core/computation/ops.py:455: error: Cannot call function of unknown type [operator]
+ pandas/core/computation/ops.py:583: error: Cannot call function of unknown type [operator]
+ pandas/core/algorithms.py:1585: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/base.py:3854: error: Cannot call function of unknown type [operator]
+ pandas/core/arrays/interval.py:1281: error: Cannot call function of unknown type [operator]
+ pandas/core/indexes/datetimes.py:854: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/datetimes.py:856: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/datetimes.py:859: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/datetimes.py:864: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/interval.py:630: error: Cannot call function of unknown type [operator]
+ pandas/core/generic.py:1503: error: Argument 1 to "inv" has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "_SupportsInv[<nothing>]" [arg-type]
+ pandas/core/generic.py:1505: error: Argument 1 to "neg" has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "_SupportsNeg[ndarray[Any, dtype[Any]]]" [arg-type]
+ pandas/core/generic.py:1517: error: Argument 1 to "pos" has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "_SupportsPos[ndarray[Any, dtype[Any]]]" [arg-type]
+ pandas/io/formats/style.py:3490: error: Incompatible types in assignment (expression has type "Tuple[overloaded function, overloaded function]", variable has type "Tuple[overloaded function, overloaded function]") [assignment]
+ pandas/io/formats/style.py:3492: error: Incompatible types in assignment (expression has type "Tuple[overloaded function, overloaded function]", variable has type "Tuple[overloaded function, overloaded function]") [assignment]
+ pandas/io/formats/style.py:3494: error: Incompatible types in assignment (expression has type "Tuple[overloaded function, overloaded function]", variable has type "Tuple[overloaded function, overloaded function]") [assignment]
+ pandas/io/formats/style.py:3511: error: Unsupported left operand type for & ("object") [operator]
|
|
Nice, the Tanjun one found a real bug (or wrong annotation). Much of the other mypy-primer output looks like false positives though. |
Yah, I kinda expected I'd get quite a few 🙂 but wanted to push it all in one go to see what would happen. Probably won't have a chance to look through the primer output until tomorrow. |
_operator.pyicurrently has a large number of functions that are only annotated withAny. I believe we can do much better than that.