Skip to content

Commit e67decb

Browse files
authored
Sync typeshed (#17586)
Source commit: python/typeshed@9eae1ae
1 parent db9837f commit e67decb

File tree

123 files changed

+1750
-936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1750
-936
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ _dummy_threading: 3.0-3.8
3535
_heapq: 3.0-
3636
_imp: 3.0-
3737
_interpchannels: 3.13-
38+
_interpqueues: 3.13-
39+
_interpreters: 3.13-
3840
_json: 3.0-
3941
_locale: 3.0-
4042
_lsprof: 3.0-
@@ -112,6 +114,7 @@ curses: 3.0-
112114
dataclasses: 3.7-
113115
datetime: 3.0-
114116
dbm: 3.0-
117+
dbm.sqlite3: 3.13-
115118
decimal: 3.0-
116119
difflib: 3.0-
117120
dis: 3.0-
@@ -155,6 +158,7 @@ importlib: 3.0-
155158
importlib._abc: 3.10-
156159
importlib.metadata: 3.8-
157160
importlib.metadata._meta: 3.10-
161+
importlib.metadata.diagnose: 3.13-
158162
importlib.readers: 3.10-
159163
importlib.resources: 3.7-
160164
importlib.resources.abc: 3.11-

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
7070
@final
7171
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
7272
def __eq__(self, value: object, /) -> bool: ...
73+
if sys.version_info >= (3, 13):
74+
def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ...
7375
if sys.version_info >= (3, 10):
7476
@property
7577
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@@ -83,6 +85,8 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
8385
@final
8486
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
8587
def __eq__(self, value: object, /) -> bool: ...
88+
if sys.version_info >= (3, 13):
89+
def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ...
8690
if sys.version_info >= (3, 10):
8791
@property
8892
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...

mypy/typeshed/stdlib/_csv.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import sys
22
from _typeshed import SupportsWrite
33
from collections.abc import Iterable, Iterator
4-
from typing import Any, Final, Literal
4+
from typing import Any, Final
55
from typing_extensions import TypeAlias
66

77
__version__: Final[str]
88

9-
QUOTE_ALL: Literal[1]
10-
QUOTE_MINIMAL: Literal[0]
11-
QUOTE_NONE: Literal[3]
12-
QUOTE_NONNUMERIC: Literal[2]
9+
QUOTE_ALL: Final = 1
10+
QUOTE_MINIMAL: Final = 0
11+
QUOTE_NONE: Final = 3
12+
QUOTE_NONNUMERIC: Final = 2
1313
if sys.version_info >= (3, 12):
14-
QUOTE_STRINGS: Literal[4]
15-
QUOTE_NOTNULL: Literal[5]
14+
QUOTE_STRINGS: Final = 4
15+
QUOTE_NOTNULL: Final = 5
1616

1717
# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC`
1818
# However, using literals in situations like these can cause false-positives (see #7258)

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ class _CData(metaclass=_CDataMeta):
6464
# Structure.from_buffer(...) # valid at runtime
6565
# Structure(...).from_buffer(...) # invalid at runtime
6666
#
67-
6867
@classmethod
6968
def from_buffer(cls, source: WriteableBuffer, offset: int = ...) -> Self: ...
7069
@classmethod
7170
def from_buffer_copy(cls, source: ReadableBuffer, offset: int = ...) -> Self: ...
7271
@classmethod
7372
def from_address(cls, address: int) -> Self: ...
7473
@classmethod
75-
def from_param(cls, obj: Any) -> Self | _CArgObject: ...
74+
def from_param(cls, value: Any, /) -> Self | _CArgObject: ...
7675
@classmethod
7776
def in_dll(cls, library: CDLL, name: str) -> Self: ...
7877
def __buffer__(self, flags: int, /) -> memoryview: ...
@@ -100,8 +99,8 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]):
10099
def __getitem__(self, key: slice, /) -> list[Any]: ...
101100
def __setitem__(self, key: int, value: Any, /) -> None: ...
102101

103-
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
104-
def pointer(arg: _CT, /) -> _Pointer[_CT]: ...
102+
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
103+
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...
105104

106105
class _CArgObject: ...
107106

@@ -199,9 +198,9 @@ class Array(_CData, Generic[_CT]):
199198
if sys.version_info >= (3, 9):
200199
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
201200

202-
def addressof(obj: _CData) -> int: ...
203-
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
201+
def addressof(obj: _CData, /) -> int: ...
202+
def alignment(obj_or_type: _CData | type[_CData], /) -> int: ...
204203
def get_errno() -> int: ...
205-
def resize(obj: _CData, size: int) -> None: ...
206-
def set_errno(value: int) -> int: ...
207-
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
204+
def resize(obj: _CData, size: int, /) -> None: ...
205+
def set_errno(value: int, /) -> int: ...
206+
def sizeof(obj_or_type: _CData | type[_CData], /) -> int: ...

mypy/typeshed/stdlib/_interpchannels.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import structseq
2-
from typing import Final, Literal, SupportsIndex, final
2+
from typing import Any, Final, Literal, SupportsIndex, final
33
from typing_extensions import Buffer, Self
44

55
class ChannelError(RuntimeError): ...
@@ -72,13 +72,15 @@ class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, in
7272
@property
7373
def send_released(self) -> bool: ...
7474

75-
def create() -> ChannelID: ...
75+
def create(unboundop: Literal[1, 2, 3]) -> ChannelID: ...
7676
def destroy(cid: SupportsIndex) -> None: ...
7777
def list_all() -> list[ChannelID]: ...
7878
def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ...
7979
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ...
8080
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ...
81-
def recv(cid: SupportsIndex, default: object = ...) -> object: ...
81+
def recv(cid: SupportsIndex, default: object = ...) -> tuple[Any, Literal[1, 2, 3]]: ...
8282
def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ...
83+
def get_count(cid: SupportsIndex) -> int: ...
8384
def get_info(cid: SupportsIndex) -> ChannelInfo: ...
85+
def get_channel_defaults(cid: SupportsIndex) -> Literal[1, 2, 3]: ...
8486
def release(cid: SupportsIndex, *, send: bool = False, recv: bool = False, force: bool = False) -> None: ...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Any, SupportsIndex
2+
3+
class QueueError(RuntimeError): ...
4+
class QueueNotFoundError(QueueError): ...
5+
6+
def bind(qid: SupportsIndex) -> None: ...
7+
def create(maxsize: SupportsIndex, fmt: SupportsIndex) -> int: ...
8+
def destroy(qid: SupportsIndex) -> None: ...
9+
def get(qid: SupportsIndex) -> tuple[Any, int]: ...
10+
def get_count(qid: SupportsIndex) -> int: ...
11+
def get_maxsize(qid: SupportsIndex) -> int: ...
12+
def get_queue_defaults(qid: SupportsIndex) -> tuple[int]: ...
13+
def is_full(qid: SupportsIndex) -> bool: ...
14+
def list_all() -> list[tuple[int, int]]: ...
15+
def put(qid: SupportsIndex, obj: Any, fmt: SupportsIndex) -> None: ...
16+
def release(qid: SupportsIndex) -> None: ...
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import types
2+
from collections.abc import Callable, Mapping
3+
from typing import Final, Literal, SupportsIndex
4+
from typing_extensions import TypeAlias
5+
6+
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
7+
8+
class InterpreterError(Exception): ...
9+
class InterpreterNotFoundError(InterpreterError): ...
10+
class NotShareableError(Exception): ...
11+
12+
class CrossInterpreterBufferView:
13+
def __buffer__(self, flags: int, /) -> memoryview: ...
14+
15+
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace: ...
16+
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int: ...
17+
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None: ...
18+
def list_all(*, require_ready: bool) -> list[tuple[int, int]]: ...
19+
def get_current() -> tuple[int, int]: ...
20+
def get_main() -> tuple[int, int]: ...
21+
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
22+
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
23+
def whence(id: SupportsIndex) -> int: ...
24+
def exec(id: SupportsIndex, code: str, shared: bool | None = None, *, restrict: bool = False) -> None: ...
25+
def call(
26+
id: SupportsIndex,
27+
callable: Callable[..., object],
28+
args: tuple[object, ...] | None = None,
29+
kwargs: dict[str, object] | None = None,
30+
*,
31+
restrict: bool = False,
32+
) -> object: ...
33+
def run_string(
34+
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
35+
) -> None: ...
36+
def run_func(
37+
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
38+
) -> None: ...
39+
def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None: ...
40+
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
41+
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
42+
def is_shareable(obj: object) -> bool: ...
43+
def capture_exception(exc: BaseException | None = None) -> types.SimpleNamespace: ...
44+
45+
WHENCE_UNKNOWN: Final = 0
46+
WHENCE_RUNTIME: Final = 1
47+
WHENCE_LEGACY_CAPI: Final = 2
48+
WHENCE_CAPI: Final = 3
49+
WHENCE_XI: Final = 4
50+
WHENCE_STDLIB: Final = 5

mypy/typeshed/stdlib/_stat.pyi

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
import sys
2-
from typing import Literal
3-
4-
SF_APPEND: Literal[0x00040000]
5-
SF_ARCHIVED: Literal[0x00010000]
6-
SF_IMMUTABLE: Literal[0x00020000]
7-
SF_NOUNLINK: Literal[0x00100000]
8-
SF_SNAPSHOT: Literal[0x00200000]
9-
10-
ST_MODE: Literal[0]
11-
ST_INO: Literal[1]
12-
ST_DEV: Literal[2]
13-
ST_NLINK: Literal[3]
14-
ST_UID: Literal[4]
15-
ST_GID: Literal[5]
16-
ST_SIZE: Literal[6]
17-
ST_ATIME: Literal[7]
18-
ST_MTIME: Literal[8]
19-
ST_CTIME: Literal[9]
20-
21-
S_IFIFO: Literal[0o010000]
22-
S_IFLNK: Literal[0o120000]
23-
S_IFREG: Literal[0o100000]
24-
S_IFSOCK: Literal[0o140000]
25-
S_IFBLK: Literal[0o060000]
26-
S_IFCHR: Literal[0o020000]
27-
S_IFDIR: Literal[0o040000]
2+
from typing import Final
3+
4+
SF_APPEND: Final = 0x00040000
5+
SF_ARCHIVED: Final = 0x00010000
6+
SF_IMMUTABLE: Final = 0x00020000
7+
SF_NOUNLINK: Final = 0x00100000
8+
SF_SNAPSHOT: Final = 0x00200000
9+
10+
ST_MODE: Final = 0
11+
ST_INO: Final = 1
12+
ST_DEV: Final = 2
13+
ST_NLINK: Final = 3
14+
ST_UID: Final = 4
15+
ST_GID: Final = 5
16+
ST_SIZE: Final = 6
17+
ST_ATIME: Final = 7
18+
ST_MTIME: Final = 8
19+
ST_CTIME: Final = 9
20+
21+
S_IFIFO: Final = 0o010000
22+
S_IFLNK: Final = 0o120000
23+
S_IFREG: Final = 0o100000
24+
S_IFSOCK: Final = 0o140000
25+
S_IFBLK: Final = 0o060000
26+
S_IFCHR: Final = 0o020000
27+
S_IFDIR: Final = 0o040000
2828

2929
# These are 0 on systems that don't support the specific kind of file.
3030
# Example: Linux doesn't support door files, so S_IFDOOR is 0 on linux.
3131
S_IFDOOR: int
3232
S_IFPORT: int
3333
S_IFWHT: int
3434

35-
S_ISUID: Literal[0o4000]
36-
S_ISGID: Literal[0o2000]
37-
S_ISVTX: Literal[0o1000]
38-
39-
S_IRWXU: Literal[0o0700]
40-
S_IRUSR: Literal[0o0400]
41-
S_IWUSR: Literal[0o0200]
42-
S_IXUSR: Literal[0o0100]
43-
44-
S_IRWXG: Literal[0o0070]
45-
S_IRGRP: Literal[0o0040]
46-
S_IWGRP: Literal[0o0020]
47-
S_IXGRP: Literal[0o0010]
48-
49-
S_IRWXO: Literal[0o0007]
50-
S_IROTH: Literal[0o0004]
51-
S_IWOTH: Literal[0o0002]
52-
S_IXOTH: Literal[0o0001]
53-
54-
S_ENFMT: Literal[0o2000]
55-
S_IREAD: Literal[0o0400]
56-
S_IWRITE: Literal[0o0200]
57-
S_IEXEC: Literal[0o0100]
58-
59-
UF_APPEND: Literal[0x00000004]
60-
UF_COMPRESSED: Literal[0x00000020] # OS X 10.6+ only
61-
UF_HIDDEN: Literal[0x00008000] # OX X 10.5+ only
62-
UF_IMMUTABLE: Literal[0x00000002]
63-
UF_NODUMP: Literal[0x00000001]
64-
UF_NOUNLINK: Literal[0x00000010]
65-
UF_OPAQUE: Literal[0x00000008]
35+
S_ISUID: Final = 0o4000
36+
S_ISGID: Final = 0o2000
37+
S_ISVTX: Final = 0o1000
38+
39+
S_IRWXU: Final = 0o0700
40+
S_IRUSR: Final = 0o0400
41+
S_IWUSR: Final = 0o0200
42+
S_IXUSR: Final = 0o0100
43+
44+
S_IRWXG: Final = 0o0070
45+
S_IRGRP: Final = 0o0040
46+
S_IWGRP: Final = 0o0020
47+
S_IXGRP: Final = 0o0010
48+
49+
S_IRWXO: Final = 0o0007
50+
S_IROTH: Final = 0o0004
51+
S_IWOTH: Final = 0o0002
52+
S_IXOTH: Final = 0o0001
53+
54+
S_ENFMT: Final = 0o2000
55+
S_IREAD: Final = 0o0400
56+
S_IWRITE: Final = 0o0200
57+
S_IEXEC: Final = 0o0100
58+
59+
UF_APPEND: Final = 0x00000004
60+
UF_COMPRESSED: Final = 0x00000020 # OS X 10.6+ only
61+
UF_HIDDEN: Final = 0x00008000 # OX X 10.5+ only
62+
UF_IMMUTABLE: Final = 0x00000002
63+
UF_NODUMP: Final = 0x00000001
64+
UF_NOUNLINK: Final = 0x00000010
65+
UF_OPAQUE: Final = 0x00000008
6666

6767
def S_IMODE(mode: int, /) -> int: ...
6868
def S_IFMT(mode: int, /) -> int: ...
@@ -84,34 +84,36 @@ if sys.platform == "win32":
8484
IO_REPARSE_TAG_APPEXECLINK: int
8585

8686
if sys.platform == "win32":
87-
FILE_ATTRIBUTE_ARCHIVE: Literal[32]
88-
FILE_ATTRIBUTE_COMPRESSED: Literal[2048]
89-
FILE_ATTRIBUTE_DEVICE: Literal[64]
90-
FILE_ATTRIBUTE_DIRECTORY: Literal[16]
91-
FILE_ATTRIBUTE_ENCRYPTED: Literal[16384]
92-
FILE_ATTRIBUTE_HIDDEN: Literal[2]
93-
FILE_ATTRIBUTE_INTEGRITY_STREAM: Literal[32768]
94-
FILE_ATTRIBUTE_NORMAL: Literal[128]
95-
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Literal[8192]
96-
FILE_ATTRIBUTE_NO_SCRUB_DATA: Literal[131072]
97-
FILE_ATTRIBUTE_OFFLINE: Literal[4096]
98-
FILE_ATTRIBUTE_READONLY: Literal[1]
99-
FILE_ATTRIBUTE_REPARSE_POINT: Literal[1024]
100-
FILE_ATTRIBUTE_SPARSE_FILE: Literal[512]
101-
FILE_ATTRIBUTE_SYSTEM: Literal[4]
102-
FILE_ATTRIBUTE_TEMPORARY: Literal[256]
103-
FILE_ATTRIBUTE_VIRTUAL: Literal[65536]
87+
FILE_ATTRIBUTE_ARCHIVE: Final = 32
88+
FILE_ATTRIBUTE_COMPRESSED: Final = 2048
89+
FILE_ATTRIBUTE_DEVICE: Final = 64
90+
FILE_ATTRIBUTE_DIRECTORY: Final = 16
91+
FILE_ATTRIBUTE_ENCRYPTED: Final = 16384
92+
FILE_ATTRIBUTE_HIDDEN: Final = 2
93+
FILE_ATTRIBUTE_INTEGRITY_STREAM: Final = 32768
94+
FILE_ATTRIBUTE_NORMAL: Final = 128
95+
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Final = 8192
96+
FILE_ATTRIBUTE_NO_SCRUB_DATA: Final = 131072
97+
FILE_ATTRIBUTE_OFFLINE: Final = 4096
98+
FILE_ATTRIBUTE_READONLY: Final = 1
99+
FILE_ATTRIBUTE_REPARSE_POINT: Final = 1024
100+
FILE_ATTRIBUTE_SPARSE_FILE: Final = 512
101+
FILE_ATTRIBUTE_SYSTEM: Final = 4
102+
FILE_ATTRIBUTE_TEMPORARY: Final = 256
103+
FILE_ATTRIBUTE_VIRTUAL: Final = 65536
104104

105105
if sys.version_info >= (3, 13):
106-
SF_SETTABLE: Literal[0x3FFF0000]
106+
# Varies by platform.
107+
SF_SETTABLE: Final[int]
107108
# https://github.com/python/cpython/issues/114081#issuecomment-2119017790
108109
# SF_RESTRICTED: Literal[0x00080000]
109-
SF_FIRMLINK: Literal[0x00800000]
110-
SF_DATALESS: Literal[0x40000000]
110+
SF_FIRMLINK: Final = 0x00800000
111+
SF_DATALESS: Final = 0x40000000
111112

112-
SF_SUPPORTED: Literal[0x9F0000]
113-
SF_SYNTHETIC: Literal[0xC0000000]
113+
if sys.platform == "darwin":
114+
SF_SUPPORTED: Final = 0x9F0000
115+
SF_SYNTHETIC: Final = 0xC0000000
114116

115-
UF_TRACKED: Literal[0x00000040]
116-
UF_DATAVAULT: Literal[0x00000080]
117-
UF_SETTABLE: Literal[0x0000FFFF]
117+
UF_TRACKED: Final = 0x00000040
118+
UF_DATAVAULT: Final = 0x00000080
119+
UF_SETTABLE: Final = 0x0000FFFF

0 commit comments

Comments
 (0)