summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <43369155+BvB93@users.noreply.github.com>2022-02-22 21:34:09 +0100
committerBas van Beek <43369155+BvB93@users.noreply.github.com>2022-02-22 21:34:09 +0100
commit99efe5768ea1451583e0e06da7ced07b1aa4419f (patch)
tree2c87ea4d9f466d24dc6475581df74ca263ac4f9b
parenta804f894153ab0cc1f47c4ab176aecc782583995 (diff)
downloadnumpy-99efe5768ea1451583e0e06da7ced07b1aa4419f.tar.gz
ENH: Mark non-subclassable types as `final`
-rw-r--r--numpy/__init__.pyi4
-rw-r--r--numpy/typing/_ufunc.pyi10
2 files changed, 9 insertions, 5 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 29fbc79b7..6def46d2c 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -930,6 +930,7 @@ _ArrayLikeInt = Union[
_FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter)
+@final
class flatiter(Generic[_NdArraySubClass]):
@property
def base(self) -> _NdArraySubClass: ...
@@ -3136,6 +3137,7 @@ UFUNC_PYVALS_NAME: L["UFUNC_PYVALS"]
newaxis: None
# See `npt._ufunc` for more concrete nin-/nout-specific stubs
+@final
class ufunc:
@property
def __name__(self) -> str: ...
@@ -3372,6 +3374,7 @@ class DataSource:
# TODO: The type of each `__next__` and `iters` return-type depends
# on the length and dtype of `args`; we can't describe this behavior yet
# as we lack variadics (PEP 646).
+@final
class broadcast:
def __new__(cls, *args: ArrayLike) -> broadcast: ...
@property
@@ -3392,6 +3395,7 @@ class broadcast:
def __iter__(self: _T) -> _T: ...
def reset(self) -> None: ...
+@final
class busdaycalendar:
def __new__(
cls,
diff --git a/numpy/typing/_ufunc.pyi b/numpy/typing/_ufunc.pyi
index 703b7f925..ee0317cf9 100644
--- a/numpy/typing/_ufunc.pyi
+++ b/numpy/typing/_ufunc.pyi
@@ -48,7 +48,7 @@ _NameType = TypeVar("_NameType", bound=str)
# NOTE: If 2 output types are returned then `out` must be a
# 2-tuple of arrays. Otherwise `None` or a plain array are also acceptable
-class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
+class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
@@ -108,7 +108,7 @@ class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
/,
) -> None: ...
-class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
+class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
@@ -223,7 +223,7 @@ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
extobj: list[Any] = ...,
) -> NDArray[Any]: ...
-class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
+class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
@@ -281,7 +281,7 @@ class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
extobj: list[Any] = ...,
) -> _2Tuple[NDArray[Any]]: ...
-class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
+class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
@@ -341,7 +341,7 @@ class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
extobj: list[Any] = ...,
) -> _2Tuple[NDArray[Any]]: ...
-class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
+class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property