Skip to content

Commit 3fcfcb8

Browse files
authored
Sync typeshed (#19664)
Source commit: python/typeshed@554701e
1 parent e30128b commit 3fcfcb8

Some content is hidden

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

45 files changed

+1104
-930
lines changed

misc/typeshed_patches/0001-Remove-use-of-LiteralString-in-builtins-13743.patch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From e6995c91231e1915eba43a29a22dd4cbfaf9e08e Mon Sep 17 00:00:00 2001
1+
From 805d7fc06a8bee350959512e0908a18a87b7f8c2 Mon Sep 17 00:00:00 2001
22
From: Shantanu <[email protected]>
33
Date: Mon, 26 Sep 2022 12:55:07 -0700
44
Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
@@ -8,7 +8,7 @@ Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
88
1 file changed, 1 insertion(+), 99 deletions(-)
99

1010
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
11-
index 00728f42d..ea77a730f 100644
11+
index c7ab95482..3e93da36e 100644
1212
--- a/mypy/typeshed/stdlib/builtins.pyi
1313
+++ b/mypy/typeshed/stdlib/builtins.pyi
1414
@@ -63,7 +63,6 @@ from typing import ( # noqa: Y022,UP035
@@ -19,7 +19,7 @@ index 00728f42d..ea77a730f 100644
1919
ParamSpec,
2020
Self,
2121
TypeAlias,
22-
@@ -453,31 +452,16 @@ class str(Sequence[str]):
22+
@@ -468,31 +467,16 @@ class str(Sequence[str]):
2323
def __new__(cls, object: object = ...) -> Self: ...
2424
@overload
2525
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
@@ -51,7 +51,7 @@ index 00728f42d..ea77a730f 100644
5151
def format(self, *args: object, **kwargs: object) -> str: ...
5252
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
5353
def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
54-
@@ -493,98 +477,34 @@ class str(Sequence[str]):
54+
@@ -508,98 +492,34 @@ class str(Sequence[str]):
5555
def isspace(self) -> bool: ...
5656
def istitle(self) -> bool: ...
5757
def isupper(self) -> bool: ...
@@ -150,7 +150,7 @@ index 00728f42d..ea77a730f 100644
150150
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
151151
@staticmethod
152152
@overload
153-
@@ -595,39 +515,21 @@ class str(Sequence[str]):
153+
@@ -610,39 +530,21 @@ class str(Sequence[str]):
154154
@staticmethod
155155
@overload
156156
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
@@ -190,7 +190,7 @@ index 00728f42d..ea77a730f 100644
190190
- @overload
191191
def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
192192
def __getnewargs__(self) -> tuple[str]: ...
193-
193+
def __format__(self, format_spec: str, /) -> str: ...
194194
--
195-
2.49.0
195+
2.50.1
196196

mypy/typeshed/stdlib/_contextvars.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Token(Generic[_T]):
3939
if sys.version_info >= (3, 14):
4040
def __enter__(self) -> Self: ...
4141
def __exit__(
42-
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
42+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
4343
) -> None: ...
4444

4545
def copy_context() -> Context: ...

mypy/typeshed/stdlib/_frozen_importlib.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from _typeshed.importlib import LoaderProtocol
66
from collections.abc import Mapping, Sequence
77
from types import ModuleType
88
from typing import Any, ClassVar
9+
from typing_extensions import deprecated
910

1011
# Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
1112
def __import__(
@@ -49,6 +50,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
4950
# MetaPathFinder
5051
if sys.version_info < (3, 12):
5152
@classmethod
53+
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
5254
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
5355

5456
@classmethod
@@ -67,6 +69,10 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
6769
# Loader
6870
if sys.version_info < (3, 12):
6971
@staticmethod
72+
@deprecated(
73+
"Deprecated since Python 3.4; removed in Python 3.12. "
74+
"The module spec is now used by the import machinery to generate a module repr."
75+
)
7076
def module_repr(module: types.ModuleType) -> str: ...
7177
if sys.version_info >= (3, 10):
7278
@staticmethod
@@ -83,6 +89,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
8389
# MetaPathFinder
8490
if sys.version_info < (3, 12):
8591
@classmethod
92+
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
8693
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
8794

8895
@classmethod
@@ -101,6 +108,10 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
101108
# Loader
102109
if sys.version_info < (3, 12):
103110
@staticmethod
111+
@deprecated(
112+
"Deprecated since Python 3.4; removed in Python 3.12. "
113+
"The module spec is now used by the import machinery to generate a module repr."
114+
)
104115
def module_repr(m: types.ModuleType) -> str: ...
105116
if sys.version_info >= (3, 10):
106117
@staticmethod

mypy/typeshed/stdlib/_frozen_importlib_external.pyi

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def spec_from_file_location(
4343
class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
4444
if sys.version_info < (3, 12):
4545
@classmethod
46+
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
4647
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
4748

4849
@classmethod
@@ -70,6 +71,7 @@ class PathFinder(importlib.abc.MetaPathFinder):
7071
) -> ModuleSpec | None: ...
7172
if sys.version_info < (3, 12):
7273
@classmethod
74+
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
7375
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
7476

7577
SOURCE_SUFFIXES: list[str]
@@ -158,7 +160,10 @@ if sys.version_info >= (3, 11):
158160
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
159161
if sys.version_info < (3, 12):
160162
@staticmethod
161-
@deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
163+
@deprecated(
164+
"Deprecated since Python 3.4; removed in Python 3.12. "
165+
"The module spec is now used by the import machinery to generate a module repr."
166+
)
162167
def module_repr(module: types.ModuleType) -> str: ...
163168

164169
_NamespaceLoader = NamespaceLoader
@@ -176,12 +181,18 @@ else:
176181
def load_module(self, fullname: str) -> types.ModuleType: ...
177182
if sys.version_info >= (3, 10):
178183
@staticmethod
179-
@deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
184+
@deprecated(
185+
"Deprecated since Python 3.4; removed in Python 3.12. "
186+
"The module spec is now used by the import machinery to generate a module repr."
187+
)
180188
def module_repr(module: types.ModuleType) -> str: ...
181189
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
182190
else:
183191
@classmethod
184-
@deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
192+
@deprecated(
193+
"Deprecated since Python 3.4; removed in Python 3.12. "
194+
"The module spec is now used by the import machinery to generate a module repr."
195+
)
185196
def module_repr(cls, module: types.ModuleType) -> str: ...
186197

187198
if sys.version_info >= (3, 13):

mypy/typeshed/stdlib/_interpchannels.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ class ChannelID:
1717
def send(self) -> Self: ...
1818
@property
1919
def recv(self) -> Self: ...
20-
def __eq__(self, other: object) -> bool: ...
21-
def __ge__(self, other: ChannelID) -> bool: ...
22-
def __gt__(self, other: ChannelID) -> bool: ...
20+
def __eq__(self, other: object, /) -> bool: ...
21+
def __ge__(self, other: ChannelID, /) -> bool: ...
22+
def __gt__(self, other: ChannelID, /) -> bool: ...
2323
def __hash__(self) -> int: ...
2424
def __index__(self) -> int: ...
2525
def __int__(self) -> int: ...
26-
def __le__(self, other: ChannelID) -> bool: ...
27-
def __lt__(self, other: ChannelID) -> bool: ...
28-
def __ne__(self, other: object) -> bool: ...
26+
def __le__(self, other: ChannelID, /) -> bool: ...
27+
def __lt__(self, other: ChannelID, /) -> bool: ...
28+
def __ne__(self, other: object, /) -> bool: ...
2929

3030
@final
3131
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):

mypy/typeshed/stdlib/_interpreters.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def exec(
3434
def call(
3535
id: SupportsIndex,
3636
callable: Callable[..., _R],
37-
args: tuple[object, ...] | None = None,
38-
kwargs: dict[str, object] | None = None,
37+
args: tuple[Any, ...] | None = None,
38+
kwargs: dict[str, Any] | None = None,
3939
*,
4040
restrict: bool = False,
4141
) -> tuple[_R, types.SimpleNamespace]: ...

0 commit comments

Comments
 (0)