diff --git a/numpy/ma/core.pyi b/numpy/ma/core.pyi index 6ce080ada9fb..555a722c3b7a 100644 --- a/numpy/ma/core.pyi +++ b/numpy/ma/core.pyi @@ -230,8 +230,8 @@ _ScalarT_co = TypeVar("_ScalarT_co", bound=generic) # A subset of `MaskedArray` that can be parametrized w.r.t. `np.generic` _MaskedArray: TypeAlias = MaskedArray[_Shape, dtype[_ScalarT]] -MaskType = bool -nomask: bool +MaskType = bool_ +nomask: bool_[Literal[False]] class MaskedArrayFutureWarning(FutureWarning): ... class MAError(Exception): ... diff --git a/numpy/typing/tests/data/reveal/ma.pyi b/numpy/typing/tests/data/reveal/ma.pyi index 8c49d989c1ca..4a40a8d536a2 100644 --- a/numpy/typing/tests/data/reveal/ma.pyi +++ b/numpy/typing/tests/data/reveal/ma.pyi @@ -1,5 +1,5 @@ from datetime import datetime, timedelta -from typing import Any, TypeAlias, TypeVar, assert_type +from typing import Any, Literal, TypeAlias, TypeVar, assert_type import numpy as np from numpy import dtype, generic @@ -280,3 +280,7 @@ assert_type(np.ma.allequal(AR_f4, MAR_f4, fill_value=False), bool) assert_type(np.ma.allclose(AR_f4, MAR_f4), bool) assert_type(np.ma.allclose(AR_f4, MAR_f4, masked_equal=False), bool) assert_type(np.ma.allclose(AR_f4, MAR_f4, rtol=.4, atol=.3), bool) + +assert_type(np.ma.nomask, np.bool[Literal[False]]) +# https://github.com/python/mypy/issues/18974 +assert_type(np.ma.MaskType, type[np.bool]) # type: ignore[assert-type]