Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd163747

Browse files
jorenhamcharris
authored andcommitted
TYP: add missing"b1" literals fordtype[bool]
1 parent9f2ce36 commitd163747

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎numpy/_typing/_char_codes.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
fromtypingimportLiteral
22

3-
_BoolCodes=Literal["bool","bool_","?","|?","=?","<?",">?"]
3+
_BoolCodes=Literal[
4+
"bool","bool_",
5+
"?","|?","=?","<?",">?",
6+
"b1","|b1","=b1","<b1",">b1",
7+
]# fmt: skip
48

59
_UInt8Codes=Literal["uint8","u1","|u1","=u1","<u1",">u1"]
610
_UInt16Codes=Literal["uint16","u2","|u2","=u2","<u2",">u2"]

‎numpy/typing/tests/data/reveal/dtype.pyi‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from typing import Any, Literal, TypeAlias
77
importnumpyasnp
88
fromnumpy.dtypesimportStringDType
99

10-
fromtyping_extensionsimportassert_type
10+
fromtyping_extensionsimportLiteralString,assert_type
1111

1212
# a combination of likely `object` dtype-like candidates (no `_co`)
1313
_PyObjectLike:TypeAlias=Decimal|Fraction|dt.datetime|dt.timedelta
@@ -71,6 +71,8 @@ assert_type(np.dtype(Decimal), np.dtype[np.object_])
7171
assert_type(np.dtype(Fraction),np.dtype[np.object_])
7272

7373
# char-codes
74+
assert_type(np.dtype("?"),np.dtype[np.bool])
75+
assert_type(np.dtype("|b1"),np.dtype[np.bool])
7476
assert_type(np.dtype("u1"),np.dtype[np.uint8])
7577
assert_type(np.dtype("l"),np.dtype[np.long])
7678
assert_type(np.dtype("longlong"),np.dtype[np.longlong])
@@ -113,7 +115,7 @@ assert_type(dtype_U.base, np.dtype[Any])
113115
assert_type(dtype_U.subdtype,None|tuple[np.dtype[Any],tuple[int, ...]])
114116
assert_type(dtype_U.newbyteorder(),np.dtype[np.str_])
115117
assert_type(dtype_U.type,type[np.str_])
116-
assert_type(dtype_U.name,str)
118+
assert_type(dtype_U.name,LiteralString)
117119
assert_type(dtype_U.names,None|tuple[str, ...])
118120

119121
assert_type(dtype_U*0,np.dtype[np.str_])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp