Skip to content

Commit 4ba2696

Browse files
authored
Update typeshed (#17409)
The automatic sync failed due to a merge conflict. Source commit: python/typeshed@6dda799
1 parent 6877d6f commit 4ba2696

Some content is hidden

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

42 files changed

+630
-188
lines changed

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 5c00e362d40aa26e0a22a740f05a52d05edf0f91 Mon Sep 17 00:00:00 2001
1+
From 3ec9b878d6bbe3fae64a508a62372f10a886406f 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)
55

66
---
7-
mypy/typeshed/stdlib/builtins.pyi | 88 -------------------------------
8-
1 file changed, 88 deletions(-)
7+
mypy/typeshed/stdlib/builtins.pyi | 95 -------------------------------
8+
1 file changed, 95 deletions(-)
99

1010
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
11-
index b4765b26c..99919c64c 100644
11+
index 53e00ec6a..bad3250ef 100644
1212
--- a/mypy/typeshed/stdlib/builtins.pyi
1313
+++ b/mypy/typeshed/stdlib/builtins.pyi
1414
@@ -61,7 +61,6 @@ from typing import ( # noqa: Y022
@@ -19,7 +19,7 @@ index b4765b26c..99919c64c 100644
1919
ParamSpec,
2020
Self,
2121
TypeAlias,
22-
@@ -434,31 +433,16 @@ class str(Sequence[str]):
22+
@@ -435,31 +434,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: ...
@@ -49,9 +49,9 @@ index b4765b26c..99919c64c 100644
4949
- def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
5050
- @overload
5151
def format(self, *args: object, **kwargs: object) -> str: ...
52-
def format_map(self, map: _FormatMapMapping) -> str: ...
52+
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
5353
def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
54-
@@ -474,89 +458,32 @@ class str(Sequence[str]):
54+
@@ -475,99 +459,35 @@ class str(Sequence[str]):
5555
def isspace(self) -> bool: ...
5656
def istitle(self) -> bool: ...
5757
def isupper(self) -> bool: ...
@@ -75,10 +75,20 @@ index b4765b26c..99919c64c 100644
7575
- def partition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...
7676
- @overload
7777
def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]
78-
- @overload
79-
- def replace(self: LiteralString, old: LiteralString, new: LiteralString, count: SupportsIndex = -1, /) -> LiteralString: ...
80-
- @overload
81-
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
78+
if sys.version_info >= (3, 13):
79+
- @overload
80+
- def replace(
81+
- self: LiteralString, old: LiteralString, new: LiteralString, /, count: SupportsIndex = -1
82+
- ) -> LiteralString: ...
83+
- @overload
84+
def replace(self, old: str, new: str, /, count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
85+
else:
86+
- @overload
87+
- def replace(
88+
- self: LiteralString, old: LiteralString, new: LiteralString, count: SupportsIndex = -1, /
89+
- ) -> LiteralString: ...
90+
- @overload
91+
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
8292
if sys.version_info >= (3, 9):
8393
- @overload
8494
- def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...
@@ -141,7 +151,7 @@ index b4765b26c..99919c64c 100644
141151
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
142152
@staticmethod
143153
@overload
144-
@@ -567,9 +494,6 @@ class str(Sequence[str]):
154+
@@ -578,9 +498,6 @@ class str(Sequence[str]):
145155
@staticmethod
146156
@overload
147157
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
@@ -151,7 +161,7 @@ index b4765b26c..99919c64c 100644
151161
def __add__(self, value: str, /) -> str: ... # type: ignore[misc]
152162
# Incompatible with Sequence.__contains__
153163
def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]
154-
@@ -578,25 +502,13 @@ class str(Sequence[str]):
164+
@@ -589,25 +506,13 @@ class str(Sequence[str]):
155165
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
156166
def __gt__(self, value: str, /) -> bool: ...
157167
def __hash__(self) -> int: ...
@@ -178,5 +188,5 @@ index b4765b26c..99919c64c 100644
178188
def __getnewargs__(self) -> tuple[str]: ...
179189

180190
--
181-
2.39.3 (Apple Git-146)
191+
2.45.2
182192

mypy/typeshed/stdlib/VERSIONS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ array: 3.0-
6565
ast: 3.0-
6666
asynchat: 3.0-3.11
6767
asyncio: 3.4-
68-
asyncio.mixins: 3.10-
6968
asyncio.exceptions: 3.8-
7069
asyncio.format_helpers: 3.7-
70+
asyncio.mixins: 3.10-
7171
asyncio.runners: 3.7-
7272
asyncio.staggered: 3.8-
7373
asyncio.taskgroups: 3.11-
@@ -270,6 +270,7 @@ threading: 3.0-
270270
time: 3.0-
271271
timeit: 3.0-
272272
tkinter: 3.0-
273+
tkinter.tix: 3.0-3.12
273274
token: 3.0-
274275
tokenize: 3.0-
275276
tomllib: 3.11-

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ PyCF_ONLY_AST: Literal[1024]
77
PyCF_TYPE_COMMENTS: Literal[4096]
88
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
99

10+
if sys.version_info >= (3, 13):
11+
PyCF_OPTIMIZED_AST: Literal[33792]
12+
1013
# Used for node end positions in constructor keyword arguments
11-
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None) # noqa: Y023
14+
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None)
1215

1316
# Alias used for fields that must always be valid identifiers
1417
# A string `x` counts as a valid identifier if both the following are True

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ A_COLOR: int
6363
A_DIM: int
6464
A_HORIZONTAL: int
6565
A_INVIS: int
66-
if sys.platform != "darwin":
67-
A_ITALIC: int
66+
A_ITALIC: int
6867
A_LEFT: int
6968
A_LOW: int
7069
A_NORMAL: int

mypy/typeshed/stdlib/_json.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ class make_scanner:
4545
def __init__(self, context: make_scanner) -> None: ...
4646
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...
4747

48-
def encode_basestring_ascii(s: str) -> str: ...
48+
def encode_basestring_ascii(s: str, /) -> str: ...
4949
def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...

mypy/typeshed/stdlib/_tkinter.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import sys
2+
from collections.abc import Callable
23
from typing import Any, ClassVar, Literal, final
4+
from typing_extensions import TypeAlias
35

46
# _tkinter is meant to be only used internally by tkinter, but some tkinter
57
# functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl
@@ -30,6 +32,8 @@ class Tcl_Obj:
3032

3133
class TclError(Exception): ...
3234

35+
_TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
36+
3337
# This class allows running Tcl code. Tkinter uses it internally a lot, and
3438
# it's often handy to drop a piece of Tcl code into a tkinter program. Example:
3539
#
@@ -86,6 +90,9 @@ class TkappType:
8690
def unsetvar(self, *args, **kwargs): ...
8791
def wantobjects(self, *args, **kwargs): ...
8892
def willdispatch(self): ...
93+
if sys.version_info >= (3, 12):
94+
def gettrace(self, /) -> _TkinterTraceFunc | None: ...
95+
def settrace(self, func: _TkinterTraceFunc | None, /) -> None: ...
8996

9097
# These should be kept in sync with tkinter.tix constants, except ALL_EVENTS which doesn't match TCL_ALL_EVENTS
9198
ALL_EVENTS: Literal[-3]

mypy/typeshed/stdlib/_weakref.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class ProxyType(Generic[_T]): # "weakproxy"
2121
def __getattr__(self, attr: str) -> Any: ...
2222

2323
class ReferenceType(Generic[_T]):
24-
__callback__: Callable[[ReferenceType[_T]], Any]
25-
def __new__(cls, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ..., /) -> Self: ...
24+
__callback__: Callable[[Self], Any]
25+
def __new__(cls, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> Self: ...
26+
def __init__(self, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> None: ...
2627
def __call__(self) -> _T | None: ...
2728
def __eq__(self, value: object, /) -> bool: ...
2829
def __hash__(self) -> int: ...

mypy/typeshed/stdlib/ast.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,6 @@ def walk(node: AST) -> Iterator[AST]: ...
365365

366366
if sys.version_info >= (3, 9):
367367
def main() -> None: ...
368+
369+
if sys.version_info >= (3, 14):
370+
def compare(left: AST, right: AST, /, *, compare_attributes: bool = False) -> bool: ...

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class str(Sequence[str]):
445445
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
446446
def find(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
447447
def format(self, *args: object, **kwargs: object) -> str: ...
448-
def format_map(self, map: _FormatMapMapping) -> str: ...
448+
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
449449
def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
450450
def isalnum(self) -> bool: ...
451451
def isalpha(self) -> bool: ...
@@ -464,7 +464,10 @@ class str(Sequence[str]):
464464
def lower(self) -> str: ... # type: ignore[misc]
465465
def lstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
466466
def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]
467-
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
467+
if sys.version_info >= (3, 13):
468+
def replace(self, old: str, new: str, /, count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
469+
else:
470+
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
468471
if sys.version_info >= (3, 9):
469472
def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
470473
def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]
@@ -1126,6 +1129,9 @@ class property:
11261129
fset: Callable[[Any, Any], None] | None
11271130
fdel: Callable[[Any], None] | None
11281131
__isabstractmethod__: bool
1132+
if sys.version_info >= (3, 13):
1133+
__name__: str
1134+
11291135
def __init__(
11301136
self,
11311137
fget: Callable[[Any], Any] | None = ...,
@@ -1969,3 +1975,7 @@ if sys.version_info >= (3, 11):
19691975
def split(
19701976
self, condition: Callable[[_ExceptionT_co | Self], bool], /
19711977
) -> tuple[ExceptionGroup[_ExceptionT_co] | None, ExceptionGroup[_ExceptionT_co] | None]: ...
1978+
1979+
if sys.version_info >= (3, 13):
1980+
class IncompleteInputError(SyntaxError): ...
1981+
class PythonFinalizationError(RuntimeError): ...

0 commit comments

Comments
 (0)