MilanStaffehl / numdantic

Typing support for numpy arrays and numpy array validation with pydantic.
MIT License
2 stars 0 forks source link

Fix wrong information about dtype errors in assignments #2

Closed MilanStaffehl closed 2 months ago

MilanStaffehl commented 2 months ago

Documentation reads the following under "Limitations":

dtypes are typed correctly, so the following code will in fact cause type checkers to issue and error message:

import numpy as np
from numdantic import NDArray, Shape

# This does cause a type checking error
x: NDArray[Shape[int, int], np.float32] = np.array([[1, 2], [3, 4]], dtype=np.int32) 

This is wrong. mypy does not issue an error and passes.