Skip to content

Commit 8859d51

Browse files
Sync typeshed (python#18467)
Sync typeshed Source commit: python/typeshed@1012870
1 parent a8ab85d commit 8859d51

File tree

10 files changed

+45
-31
lines changed

10 files changed

+45
-31
lines changed
+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
from typing import Any, SupportsIndex
1+
from typing import Any, Literal, SupportsIndex
2+
from typing_extensions import TypeAlias
3+
4+
_UnboundOp: TypeAlias = Literal[1, 2, 3]
25

36
class QueueError(RuntimeError): ...
47
class QueueNotFoundError(QueueError): ...
58

69
def bind(qid: SupportsIndex) -> None: ...
7-
def create(maxsize: SupportsIndex, fmt: SupportsIndex) -> int: ...
10+
def create(maxsize: SupportsIndex, fmt: SupportsIndex, unboundop: _UnboundOp) -> int: ...
811
def destroy(qid: SupportsIndex) -> None: ...
9-
def get(qid: SupportsIndex) -> tuple[Any, int]: ...
12+
def get(qid: SupportsIndex) -> tuple[Any, int, _UnboundOp | None]: ...
1013
def get_count(qid: SupportsIndex) -> int: ...
1114
def get_maxsize(qid: SupportsIndex) -> int: ...
12-
def get_queue_defaults(qid: SupportsIndex) -> tuple[int]: ...
15+
def get_queue_defaults(qid: SupportsIndex) -> tuple[int, _UnboundOp]: ...
1316
def is_full(qid: SupportsIndex) -> bool: ...
14-
def list_all() -> list[tuple[int, int]]: ...
15-
def put(qid: SupportsIndex, obj: Any, fmt: SupportsIndex) -> None: ...
17+
def list_all() -> list[tuple[int, int, _UnboundOp]]: ...
18+
def put(qid: SupportsIndex, obj: Any, fmt: SupportsIndex, unboundop: _UnboundOp) -> None: ...
1619
def release(qid: SupportsIndex) -> None: ...

mypy/typeshed/stdlib/_interpreters.pyi

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def get_main() -> tuple[int, int]: ...
2121
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
2222
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
2323
def whence(id: SupportsIndex) -> int: ...
24-
def exec(id: SupportsIndex, code: str, shared: bool | None = None, *, restrict: bool = False) -> None: ...
24+
def exec(
25+
id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
26+
) -> None | types.SimpleNamespace: ...
2527
def call(
2628
id: SupportsIndex,
2729
callable: Callable[..., object],

mypy/typeshed/stdlib/_ssl.pyi

+1-3
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ OP_SINGLE_ECDH_USE: int
240240
OP_NO_COMPRESSION: int
241241
OP_ENABLE_MIDDLEBOX_COMPAT: int
242242
OP_NO_RENEGOTIATION: int
243-
if sys.version_info >= (3, 11):
244-
OP_IGNORE_UNEXPECTED_EOF: int
245-
elif sys.version_info >= (3, 8) and sys.platform == "linux":
243+
if sys.version_info >= (3, 11) or sys.platform == "linux":
246244
OP_IGNORE_UNEXPECTED_EOF: int
247245
if sys.version_info >= (3, 12):
248246
OP_LEGACY_SERVER_CONNECT: int

mypy/typeshed/stdlib/ctypes/__init__.pyi

+8-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,14 @@ def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to
159159
if sys.platform == "win32":
160160
def DllCanUnloadNow() -> int: ...
161161
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
162-
def GetLastError() -> int: ...
162+
163+
# Actually just an instance of _NamedFuncPointer (aka _CDLLFuncPointer),
164+
# but we want to set a more specific __call__
165+
@type_check_only
166+
class _GetLastErrorFunctionType(_NamedFuncPointer):
167+
def __call__(self) -> int: ...
168+
169+
GetLastError: _GetLastErrorFunctionType
163170

164171
# Actually just an instance of _CFunctionType, but we want to set a more
165172
# specific __call__.

mypy/typeshed/stdlib/socket.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ def create_server(
13991399
address: _Address, *, family: int = ..., backlog: int | None = None, reuse_port: bool = False, dualstack_ipv6: bool = False
14001400
) -> socket: ...
14011401

1402-
# the 5th tuple item is an address
1402+
# The 5th tuple item is the socket address, for IP4, IP6, or IP6 if Python is compiled with --disable-ipv6, respectively.
14031403
def getaddrinfo(
14041404
host: bytes | str | None, port: bytes | str | int | None, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0
1405-
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
1405+
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]: ...

mypy/typeshed/stdlib/sys/__init__.pyi

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from collections.abc import AsyncGenerator, Callable, Sequence
66
from io import TextIOWrapper
77
from types import FrameType, ModuleType, TracebackType
88
from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, type_check_only
9-
from typing_extensions import TypeAlias
9+
from typing_extensions import LiteralString, TypeAlias
1010

1111
_T = TypeVar("_T")
1212

@@ -45,7 +45,7 @@ if sys.version_info >= (3, 10):
4545
path: list[str]
4646
path_hooks: list[Callable[[str], PathEntryFinderProtocol]]
4747
path_importer_cache: dict[str, PathEntryFinderProtocol | None]
48-
platform: str
48+
platform: LiteralString
4949
if sys.version_info >= (3, 9):
5050
platlibdir: str
5151
prefix: str
@@ -393,6 +393,10 @@ if sys.platform == "win32":
393393
def getwindowsversion() -> _WinVersion: ...
394394

395395
def intern(string: str, /) -> str: ...
396+
397+
if sys.version_info >= (3, 13):
398+
def _is_gil_enabled() -> bool: ...
399+
396400
def is_finalizing() -> bool: ...
397401
def breakpointhook(*args: Any, **kwargs: Any) -> Any: ...
398402

mypy/typeshed/stdlib/tarfile.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def open(
123123
@overload
124124
def open(
125125
name: StrOrBytesPath | None,
126-
mode: Literal["x", "x:", "a", "a:", "w", "w:"],
126+
mode: Literal["x", "x:", "a", "a:", "w", "w:", "w:tar"],
127127
fileobj: _Fileobj | None = None,
128128
bufsize: int = 10240,
129129
*,
@@ -141,7 +141,7 @@ def open(
141141
def open(
142142
name: StrOrBytesPath | None = None,
143143
*,
144-
mode: Literal["x", "x:", "a", "a:", "w", "w:"],
144+
mode: Literal["x", "x:", "a", "a:", "w", "w:", "w:tar"],
145145
fileobj: _Fileobj | None = None,
146146
bufsize: int = 10240,
147147
format: int | None = ...,

mypy/typeshed/stdlib/telnetlib.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import socket
2-
from collections.abc import Callable, Sequence
2+
from collections.abc import Callable, MutableSequence, Sequence
33
from re import Match, Pattern
44
from types import TracebackType
55
from typing import Any
@@ -114,7 +114,7 @@ class Telnet:
114114
def mt_interact(self) -> None: ...
115115
def listener(self) -> None: ...
116116
def expect(
117-
self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = None
117+
self, list: MutableSequence[Pattern[bytes] | bytes] | Sequence[Pattern[bytes]], timeout: float | None = None
118118
) -> tuple[int, Match[bytes] | None, bytes]: ...
119119
def __enter__(self) -> Self: ...
120120
def __exit__(

mypy/typeshed/stdlib/tkinter/filedialog.pyi

+9-9
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class Directory(commondialog.Dialog):
8080
# TODO: command kwarg available on macos
8181
def asksaveasfilename(
8282
*,
83-
confirmoverwrite: bool | None = ...,
84-
defaultextension: str | None = ...,
83+
confirmoverwrite: bool | None = True,
84+
defaultextension: str | None = "",
8585
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
8686
initialdir: StrOrBytesPath | None = ...,
8787
initialfile: StrOrBytesPath | None = ...,
@@ -91,7 +91,7 @@ def asksaveasfilename(
9191
) -> str: ... # can be empty string
9292
def askopenfilename(
9393
*,
94-
defaultextension: str | None = ...,
94+
defaultextension: str | None = "",
9595
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
9696
initialdir: StrOrBytesPath | None = ...,
9797
initialfile: StrOrBytesPath | None = ...,
@@ -101,7 +101,7 @@ def askopenfilename(
101101
) -> str: ... # can be empty string
102102
def askopenfilenames(
103103
*,
104-
defaultextension: str | None = ...,
104+
defaultextension: str | None = "",
105105
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
106106
initialdir: StrOrBytesPath | None = ...,
107107
initialfile: StrOrBytesPath | None = ...,
@@ -110,15 +110,15 @@ def askopenfilenames(
110110
typevariable: StringVar | str | None = ...,
111111
) -> Literal[""] | tuple[str, ...]: ...
112112
def askdirectory(
113-
*, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ...
113+
*, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = False, parent: Misc | None = ..., title: str | None = ...
114114
) -> str: ... # can be empty string
115115

116116
# TODO: If someone actually uses these, overload to have the actual return type of open(..., mode)
117117
def asksaveasfile(
118118
mode: str = "w",
119119
*,
120-
confirmoverwrite: bool | None = ...,
121-
defaultextension: str | None = ...,
120+
confirmoverwrite: bool | None = True,
121+
defaultextension: str | None = "",
122122
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
123123
initialdir: StrOrBytesPath | None = ...,
124124
initialfile: StrOrBytesPath | None = ...,
@@ -129,7 +129,7 @@ def asksaveasfile(
129129
def askopenfile(
130130
mode: str = "r",
131131
*,
132-
defaultextension: str | None = ...,
132+
defaultextension: str | None = "",
133133
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
134134
initialdir: StrOrBytesPath | None = ...,
135135
initialfile: StrOrBytesPath | None = ...,
@@ -140,7 +140,7 @@ def askopenfile(
140140
def askopenfiles(
141141
mode: str = "r",
142142
*,
143-
defaultextension: str | None = ...,
143+
defaultextension: str | None = "",
144144
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
145145
initialdir: StrOrBytesPath | None = ...,
146146
initialfile: StrOrBytesPath | None = ...,

mypy/typeshed/stdlib/xml/dom/minidom.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ class ReadOnlySequentialNamedNodeMap:
291291
def length(self) -> int: ...
292292

293293
class Identified:
294-
publicId: Incomplete
295-
systemId: Incomplete
294+
publicId: str | None
295+
systemId: str | None
296296

297297
class DocumentType(Identified, Childless, Node):
298298
nodeType: int
@@ -331,7 +331,7 @@ class Notation(Identified, Childless, Node):
331331
class DOMImplementation(DOMImplementationLS):
332332
def hasFeature(self, feature: str, version: str | None) -> bool: ...
333333
def createDocument(self, namespaceURI: str | None, qualifiedName: str | None, doctype: DocumentType | None) -> Document: ...
334-
def createDocumentType(self, qualifiedName: str | None, publicId: str, systemId: str) -> DocumentType: ...
334+
def createDocumentType(self, qualifiedName: str | None, publicId: str | None, systemId: str | None) -> DocumentType: ...
335335
def getInterface(self, feature: str) -> Self | None: ...
336336

337337
class ElementInfo:

0 commit comments

Comments
 (0)