GeezerVison is showing github.com — TYP: Work around a mypy issue with bool arrays · numpy/numpy@0a180ad
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: numpy/__init__.pyi +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3846,14 +3846,14 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]): | 3846 | 3846 | @property | 3847 | 3847 | def imag(self) -> np.bool[L[False]]: ... | 3848 | 3848 |
| 3849 | | - @overload | 3850 | | - def __init__(self: np.bool[L[False]], /) -> None: ... | | 3849 | + @overload # mypy bug workaround: https://github.com/numpy/numpy/issues/29245 | | 3850 | + def __init__(self: np.bool[builtins.bool], value: Never, /) -> None: ... | 3851 | 3851 | @overload | 3852 | 3852 | def __init__(self: np.bool[L[False]], value: _Falsy = ..., /) -> None: ... | 3853 | 3853 | @overload | 3854 | 3854 | def __init__(self: np.bool[L[True]], value: _Truthy, /) -> None: ... | 3855 | 3855 | @overload | 3856 | | - def __init__(self, value: object, /) -> None: ... | | 3856 | + def __init__(self: np.bool[builtins.bool], value: object, /) -> None: ... | 3857 | 3857 |
| 3858 | 3858 | def __bool__(self, /) -> _BoolItemT_co: ... | 3859 | 3859 | @overload | |
Collapse file Copy file name to clipboardExpand all lines: numpy/typing/tests/data/reveal/array_constructors.pyi +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,6 +39,8 @@ assert_type(np.array(B, subok=True), SubClass[np.float64]) | 39 | 39 | assert_type(np.array(B, subok=True, ndmin=0), SubClass[np.float64]) | 40 | 40 | assert_type(np.array(B, subok=True, ndmin=1), SubClass[np.float64]) | 41 | 41 | assert_type(np.array(D), npt.NDArray[np.float64 | np.int64]) | | 42 | +# https://github.com/numpy/numpy/issues/29245 | | 43 | +assert_type(np.array([], dtype=np.bool), npt.NDArray[np.bool]) | 42 | 44 |
| 43 | 45 | assert_type(np.zeros([1, 5, 6]), npt.NDArray[np.float64]) | 44 | 46 | assert_type(np.zeros([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64]) | |
Collapse file Copy file name to clipboardExpand all lines: numpy/typing/tests/data/reveal/ma.pyi +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -357,8 +357,7 @@ assert_type(MAR_b.swapaxes(0, 1), MaskedArray[np.bool]) | 357 | 357 | assert_type(MAR_2d_f4.swapaxes(1, 0), MaskedArray[np.float32]) | 358 | 358 |
| 359 | 359 | assert_type(np.ma.nomask, np.bool[Literal[False]]) | 360 | | -# https://github.com/python/mypy/issues/18974 | 361 | | -assert_type(np.ma.MaskType, type[np.bool]) # type: ignore[assert-type] | | 360 | +assert_type(np.ma.MaskType, type[np.bool]) | 362 | 361 |
| 363 | 362 | assert_type(MAR_1d.__setmask__([True, False]), None) | 364 | 363 | assert_type(MAR_1d.__setmask__(np.False_), None) | |
|