Skip to content

Conversation

@MarcoGorelli
Copy link
Member

No description provided.

@MarcoGorelli MarcoGorelli marked this pull request as ready for review August 7, 2025 14:23
@jorenham jorenham added the component: numpy.ma masked arrays label Aug 7, 2025
@jorenham jorenham self-requested a review August 7, 2025 17:41
@github-actions

This comment has been minimized.

@MarcoGorelli
Copy link
Member Author

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/index_hierarchy.py:179: error: No overload variant of "tile" matches argument types "ndarray[tuple[int], dtype[signedinteger[_64Bit]]]", "signedinteger[_32Bit | _64Bit]"  [call-overload]
+ static_frame/core/index_hierarchy.py:179: note: Possible overload variants:
+ static_frame/core/index_hierarchy.py:179: note:     def [_ScalarT: generic[Any]] tile(A: _SupportsArray[dtype[_ScalarT]] | _NestedSequence[_SupportsArray[dtype[_ScalarT]]], reps: int | Sequence[int]) -> ndarray[tuple[Any, ...], dtype[_ScalarT]]
+ static_frame/core/index_hierarchy.py:179: note:     def tile(A: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], reps: int | Sequence[int]) -> ndarray[tuple[Any, ...], dtype[Any]]

optuna (https://github.com/optuna/optuna)
+ optuna/importance/_fanova/_tree.py:177: error: Incompatible types in assignment (expression has type "floating[Any]", variable has type "float")  [assignment]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/_numba/kernels/var_.py:113: error: Incompatible types in assignment (expression has type "float", variable has type "ndarray[tuple[Any, ...], dtype[Any]]")  [assignment]
+ pandas/core/_numba/kernels/var_.py:120: error: Argument 7 to "add_var" has incompatible type "ndarray[tuple[Any, ...], dtype[Any]]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:138: error: Incompatible types in assignment (expression has type "float", variable has type "ndarray[tuple[Any, ...], dtype[Any]]")  [assignment]
+ pandas/core/_numba/kernels/var_.py:145: error: Argument 7 to "add_var" has incompatible type "ndarray[tuple[Any, ...], dtype[Any]]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:215: error: Incompatible types in assignment (expression has type "int", variable has type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]")  [assignment]
+ pandas/core/_numba/kernels/var_.py:215: error: Incompatible types in assignment (expression has type "float", variable has type "ndarray[tuple[Any, ...], Any]")  [assignment]
+ pandas/core/_numba/kernels/var_.py:217: error: Argument 2 to "add_var" has incompatible type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]"; expected "int"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:218: error: Argument 3 to "add_var" has incompatible type "ndarray[tuple[Any, ...], Any]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:219: error: Argument 4 to "add_var" has incompatible type "ndarray[tuple[Any, ...], Any]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:220: error: Argument 5 to "add_var" has incompatible type "ndarray[tuple[Any, ...], Any]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:221: error: Argument 6 to "add_var" has incompatible type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]"; expected "int"  [arg-type]
+ pandas/core/_numba/kernels/var_.py:222: error: Argument 7 to "add_var" has incompatible type "ndarray[tuple[Any, ...], Any]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/sum_.py:207: error: Incompatible types in assignment (expression has type "int", variable has type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]")  [assignment]
+ pandas/core/_numba/kernels/sum_.py:209: error: Argument 2 to "add_sum" has incompatible type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]"; expected "int"  [arg-type]
+ pandas/core/_numba/kernels/sum_.py:212: error: Argument 5 to "add_sum" has incompatible type "ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]"; expected "int"  [arg-type]
+ pandas/core/_numba/kernels/mean_.py:104: error: Incompatible types in assignment (expression has type "float", variable has type "ndarray[tuple[Any, ...], dtype[Any]]")  [assignment]
+ pandas/core/_numba/kernels/mean_.py:111: error: Argument 7 to "add_mean" has incompatible type "ndarray[tuple[Any, ...], dtype[Any]]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/mean_.py:129: error: Incompatible types in assignment (expression has type "float", variable has type "ndarray[tuple[Any, ...], dtype[Any]]")  [assignment]
+ pandas/core/_numba/kernels/mean_.py:136: error: Argument 7 to "add_mean" has incompatible type "ndarray[tuple[Any, ...], dtype[Any]]"; expected "float"  [arg-type]
+ pandas/core/_numba/kernels/mean_.py:142: error: Incompatible types in assignment (expression has type "ndarray[tuple[Any, ...], dtype[Any]]", variable has type "float")  [assignment]
+ pandas/core/indexes/multi.py:4334: error: No overload variant of "tile" matches argument types "ndarray[tuple[int], dtype[Any]]", "signedinteger[_32Bit | _64Bit]"  [call-overload]
+ pandas/core/indexes/multi.py:4334: note: Possible overload variants:
+ pandas/core/indexes/multi.py:4334: note:     def [_ScalarT: generic[Any]] tile(A: _SupportsArray[dtype[_ScalarT]] | _NestedSequence[_SupportsArray[dtype[_ScalarT]]], reps: int | Sequence[int]) -> ndarray[tuple[Any, ...], dtype[_ScalarT]]
+ pandas/core/indexes/multi.py:4334: note:     def tile(A: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], reps: int | Sequence[int]) -> ndarray[tuple[Any, ...], dtype[Any]]

colour (https://github.com/colour-science/colour)
+ colour/io/ocio.py:163: error: Incompatible return value type (got "floating[_16Bit] | floating[_32Bit] | float64", expected "ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]")  [return-value]
+ colour/io/ctl.py:313: error: Incompatible return value type (got "floating[_16Bit] | floating[_32Bit] | float64", expected "ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]")  [return-value]

🤔 can this really be due to using Incomplete instead of Any?

This reverts commit e118e1e.
@jorenham
Copy link
Member

jorenham commented Aug 11, 2025

🤔 can this really be due to using Incomplete instead of Any?

I have no idea what's going on there, to be honest. Maybe it's related to a mypy bug?

@jorenham jorenham merged commit a2f142b into numpy:main Aug 11, 2025
83 of 84 checks passed
@jorenham
Copy link
Member

Thanks!

IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants