Skip to content

Commit 996e095

Browse files
committed
ENH: Use literals for flagsobj.__getitem__ and __setitem__
1 parent c1eda8e commit 996e095

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

numpy/core/multiarray.pyi

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,25 @@ def compare_chararrays(
949949

950950
def add_docstring(__obj: Callable[..., Any], __docstring: str) -> None: ...
951951

952+
_GetItemKeys = L[
953+
"C", "CONTIGUOUS", "C_CONTIGUOUS",
954+
"F", "FORTRAN", "F_CONTIGUOUS",
955+
"W", "WRITEABLE",
956+
"B", "BEHAVED",
957+
"O", "OWNDATA",
958+
"A", "ALIGNED",
959+
"X", "WRITEBACKIFCOPY",
960+
"CA", "CARRAY",
961+
"FA", "FARRAY",
962+
"FNC",
963+
"FORC",
964+
]
965+
_SetItemKeys = L[
966+
"A", "ALIGNED",
967+
"W", "WRITABLE",
968+
"X", "WRITEBACKIFCOPY",
969+
]
970+
952971
@final
953972
class flagsobj:
954973
__hash__: None # type: ignore[assignment]
@@ -979,5 +998,5 @@ class flagsobj:
979998
def num(self) -> int: ...
980999
@property
9811000
def owndata(self) -> bool: ...
982-
def __getitem__(self, key: str) -> bool: ...
983-
def __setitem__(self, key: str, value: bool) -> None: ...
1001+
def __getitem__(self, key: _GetItemKeys) -> bool: ...
1002+
def __setitem__(self, key: _SetItemKeys, value: bool) -> None: ...

0 commit comments

Comments
 (0)