Closed
Description
Describe the issue:
Arithmetic operators like division do not take shape typing into account, resulting in false-positive type hinting issues.
Originally reported here: #27957 (comment)
Some debugging work done by @jorenham at here: #27957 (comment)
Opening a separate bug report as requested
Reproduce the code example:
import numpy as np
x = np.zeros(1)
x = x / 1
Error message:
test.py:4: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[floating[Any]]]", variable has type "ndarray[tuple[int], dtype[float64]]") [assignment]
Python and NumPy Versions:
2.2.0
3.13.0 (main, Nov 21 2024, 10:46:46) [Clang 16.0.0 (clang-1600.0.26.4)]
Type-checker version and settings:
mypy 1.11.2 (compiled: no)
mypy --strict
Additional typing packages.
No response