summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-07-08 19:33:34 -0700
committerGitHub <noreply@github.com>2021-07-08 19:33:34 -0700
commit1d7939e1d26adbedaeec98c8153ea2e37297f520 (patch)
tree6d69f32a6aa665c138be7597039f39f628736a5a /numpy
parent882f00bd47ceacbbcf34cad5d491be43fee0c99e (diff)
parent996e095c51a0889d7626efb8c47107a35637cf60 (diff)
downloadnumpy-1d7939e1d26adbedaeec98c8153ea2e37297f520.tar.gz
Merge pull request #19436 from BvB93/flagsobj2
ENH: Improve the annotations of `flagsobj`
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/multiarray.pyi32
1 files changed, 27 insertions, 5 deletions
diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi
index 072a15eb6..a7d2e6bbf 100644
--- a/numpy/core/multiarray.pyi
+++ b/numpy/core/multiarray.pyi
@@ -79,9 +79,9 @@ from numpy.typing import (
)
if sys.version_info >= (3, 8):
- from typing import SupportsIndex, Final, Literal as L
+ from typing import SupportsIndex, final, Final, Literal as L
else:
- from typing_extensions import SupportsIndex, Final, Literal as L
+ from typing_extensions import SupportsIndex, final, Final, Literal as L
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
@@ -949,9 +949,31 @@ def compare_chararrays(
def add_docstring(__obj: Callable[..., Any], __docstring: str) -> None: ...
+_GetItemKeys = L[
+ "C", "CONTIGUOUS", "C_CONTIGUOUS",
+ "F", "FORTRAN", "F_CONTIGUOUS",
+ "W", "WRITEABLE",
+ "B", "BEHAVED",
+ "O", "OWNDATA",
+ "A", "ALIGNED",
+ "X", "WRITEBACKIFCOPY",
+ "CA", "CARRAY",
+ "FA", "FARRAY",
+ "FNC",
+ "FORC",
+]
+_SetItemKeys = L[
+ "A", "ALIGNED",
+ "W", "WRITABLE",
+ "X", "WRITEBACKIFCOPY",
+]
+
+@final
class flagsobj:
+ __hash__: None # type: ignore[assignment]
aligned: bool
- updateifcopy: bool
+ # NOTE: deprecated
+ # updateifcopy: bool
writeable: bool
writebackifcopy: bool
@property
@@ -976,5 +998,5 @@ class flagsobj:
def num(self) -> int: ...
@property
def owndata(self) -> bool: ...
- def __getitem__(self, key: str) -> bool: ...
- def __setitem__(self, key: str, value: bool) -> None: ...
+ def __getitem__(self, key: _GetItemKeys) -> bool: ...
+ def __setitem__(self, key: _SetItemKeys, value: bool) -> None: ...