-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
TYP: fix stubtest errors in numpy.lib._index_tricks_impl
#28529
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
Conversation
c4c58b9
to
f6d6a92
Compare
This comment has been minimized.
This comment has been minimized.
Ported from numpy/numtype#235 --- - move `ndenumerate` and `ndindex` definitions to `lib._index_tricks_impl` - add deprecated `ndenumerate.ndincr` property - removed non-existent `ndenumerate.iter` property - remove incorrect "pass" and "reveal" type-tests for `ndenumerate.iter` - fix incorrect `ndenumerate` constructor fallback return type - fix `AxisConcatenator.makemat` signature
This comment has been minimized.
This comment has been minimized.
relevant
|
Somehow, these changes caused mypy to infer a different return type for I tried to remove the first overload of Maybe this is what Einstein meant when he used the phrase "spooky action at a distance" 🤔. |
Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code: pandas (https://github.com/pandas-dev/pandas)
- pandas/io/formats/format.py:1234: error: No overload variant matches argument type "ExtensionArray" [operator]
- pandas/io/formats/format.py:1234: note: Possible overload variants:
- pandas/io/formats/format.py:1234: note: def __and__(self, Literal[False] | numpy.bool[Literal[False]], /) -> numpy.bool[Literal[False]]
- pandas/io/formats/format.py:1234: note: def __and__(self, Literal[True] | numpy.bool[Literal[True]], /) -> numpy.bool[builtins.bool]
- pandas/io/formats/format.py:1234: note: def __and__(self, builtins.bool | numpy.bool[builtins.bool], /) -> numpy.bool[builtins.bool]
- pandas/io/formats/format.py:1234: note: def [_IntegerT: integer[Any]] __and__(self, _IntegerT, /) -> _IntegerT
- pandas/io/formats/format.py:1234: note: def __and__(self, int, /) -> numpy.bool[builtins.bool] | signedinteger[_32Bit | _64Bit]
- pandas/io/formats/format.py:1234: error: No overload variant of "__rand__" of "ndarray" matches argument type "ExtensionArray" [operator]
- pandas/io/formats/format.py:1234: note: def __rand__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]]]] | builtins.bool | _NestedSequence[builtins.bool], /) -> ndarray[tuple[int, ...], dtype[numpy.bool[builtins.bool]]]
- pandas/io/formats/format.py:1234: note: def __rand__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[unsignedinteger[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[unsignedinteger[Any]]]] | builtins.bool | _NestedSequence[builtins.bool], /) -> ndarray[tuple[int, ...], dtype[unsignedinteger[Any]]]
- pandas/io/formats/format.py:1234: note: def __rand__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]]] | builtins.bool | int | _NestedSequence[builtins.bool | int], /) -> ndarray[tuple[int, ...], dtype[signedinteger[Any]]]
- pandas/io/formats/format.py:1234: note: def __rand__(self, _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]], /) -> Any
- pandas/io/formats/format.py:1234: note: Both left and right operands are unions
- pandas/io/formats/format.py:1240: error: Incompatible types in assignment (expression has type "Any | numpy.bool[builtins.bool]", variable has type "builtins.bool | None") [assignment]
static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/index_hierarchy.py:2193: error: Argument "condition" to "dropna" of "IndexHierarchy" has incompatible type overloaded function; expected "Callable[[ndarray[Any, Any]], ndarray[Any, Any]]" [arg-type]
- static_frame/core/index_hierarchy.py:2512: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], ndarray[Any, Any]]") [assignment]
- static_frame/core/index_hierarchy.py:2524: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], ndarray[Any, Any]]") [assignment]
- static_frame/core/frame.py:4672: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], ndarray[Any, Any]]") [assignment]
- static_frame/core/frame.py:4727: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], ndarray[Any, Any]]") [assignment]
- static_frame/core/batch.py:1167: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], builtins.bool]") [assignment]
- static_frame/core/batch.py:1197: error: Incompatible default for argument "condition" (default has type overloaded function, argument has type "Callable[[ndarray[Any, Any]], builtins.bool]") [assignment]
|
and again, the diff is completely unrelated to the changes 🤷🏻 |
Hmm, well let's give it a shot. Thanks Joren. |
Ported from numpy/numtype#235
ndenumerate
andndindex
definitions tolib._index_tricks_impl
ndindex.ndincr
propertyndenumerate.iter
propertyndenumerate.iter
ndenumerate
constructor fallback return typeAxisConcatenator.makemat
signature