Skip to content

Commit 4936099

Browse files
Sync typeshed (#19959)
Source commit: python/typeshed@91055c7
1 parent 6feecce commit 4936099

File tree

19 files changed

+948
-927
lines changed

19 files changed

+948
-927
lines changed

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import sys
22
from abc import abstractmethod
33
from types import MappingProxyType
4-
from typing import ( # noqa: Y022,Y038,UP035
4+
from typing import ( # noqa: Y022,Y038,UP035,Y057
55
AbstractSet as Set,
66
AsyncGenerator as AsyncGenerator,
77
AsyncIterable as AsyncIterable,
88
AsyncIterator as AsyncIterator,
99
Awaitable as Awaitable,
10+
ByteString as ByteString,
1011
Callable as Callable,
1112
ClassVar,
1213
Collection as Collection,
@@ -59,12 +60,8 @@ __all__ = [
5960
"ValuesView",
6061
"Sequence",
6162
"MutableSequence",
63+
"ByteString",
6264
]
63-
if sys.version_info < (3, 14):
64-
from typing import ByteString as ByteString # noqa: Y057,UP035
65-
66-
__all__ += ["ByteString"]
67-
6865
if sys.version_info >= (3, 12):
6966
__all__ += ["Buffer"]
7067

mypy/typeshed/stdlib/_frozen_importlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __import__(
1313
name: str,
1414
globals: Mapping[str, object] | None = None,
1515
locals: Mapping[str, object] | None = None,
16-
fromlist: Sequence[str] = (),
16+
fromlist: Sequence[str] | None = (),
1717
level: int = 0,
1818
) -> ModuleType: ...
1919
def spec_from_loader(

mypy/typeshed/stdlib/_tkinter.pyi

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,34 @@ _TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
5454
@final
5555
class TkappType:
5656
# Please keep in sync with tkinter.Tk
57-
def adderrorinfo(self, msg, /): ...
57+
def adderrorinfo(self, msg: str, /): ...
5858
def call(self, command: Any, /, *args: Any) -> Any: ...
59-
def createcommand(self, name, func, /): ...
59+
def createcommand(self, name: str, func, /): ...
6060
if sys.platform != "win32":
61-
def createfilehandler(self, file, mask, func, /): ...
62-
def deletefilehandler(self, file, /): ...
61+
def createfilehandler(self, file, mask: int, func, /): ...
62+
def deletefilehandler(self, file, /) -> None: ...
6363

64-
def createtimerhandler(self, milliseconds, func, /): ...
65-
def deletecommand(self, name, /): ...
64+
def createtimerhandler(self, milliseconds: int, func, /): ...
65+
def deletecommand(self, name: str, /): ...
6666
def dooneevent(self, flags: int = 0, /): ...
6767
def eval(self, script: str, /) -> str: ...
68-
def evalfile(self, fileName, /): ...
69-
def exprboolean(self, s, /): ...
70-
def exprdouble(self, s, /): ...
71-
def exprlong(self, s, /): ...
72-
def exprstring(self, s, /): ...
73-
def getboolean(self, arg, /): ...
74-
def getdouble(self, arg, /): ...
75-
def getint(self, arg, /): ...
68+
def evalfile(self, fileName: str, /): ...
69+
def exprboolean(self, s: str, /): ...
70+
def exprdouble(self, s: str, /): ...
71+
def exprlong(self, s: str, /): ...
72+
def exprstring(self, s: str, /): ...
73+
def getboolean(self, arg, /) -> bool: ...
74+
def getdouble(self, arg, /) -> float: ...
75+
def getint(self, arg, /) -> int: ...
7676
def getvar(self, *args, **kwargs): ...
7777
def globalgetvar(self, *args, **kwargs): ...
7878
def globalsetvar(self, *args, **kwargs): ...
7979
def globalunsetvar(self, *args, **kwargs): ...
8080
def interpaddr(self) -> int: ...
8181
def loadtk(self) -> None: ...
82-
def mainloop(self, threshold: int = 0, /): ...
83-
def quit(self): ...
84-
def record(self, script, /): ...
82+
def mainloop(self, threshold: int = 0, /) -> None: ...
83+
def quit(self) -> None: ...
84+
def record(self, script: str, /): ...
8585
def setvar(self, *ags, **kwargs): ...
8686
if sys.version_info < (3, 11):
8787
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
@@ -90,7 +90,7 @@ class TkappType:
9090
def splitlist(self, arg, /): ...
9191
def unsetvar(self, *args, **kwargs): ...
9292
def wantobjects(self, *args, **kwargs): ...
93-
def willdispatch(self): ...
93+
def willdispatch(self) -> None: ...
9494
if sys.version_info >= (3, 12):
9595
def gettrace(self, /) -> _TkinterTraceFunc | None: ...
9696
def settrace(self, func: _TkinterTraceFunc | None, /) -> None: ...
@@ -140,5 +140,5 @@ else:
140140
/,
141141
): ...
142142

143-
def getbusywaitinterval(): ...
144-
def setbusywaitinterval(new_val, /): ...
143+
def getbusywaitinterval() -> int: ...
144+
def setbusywaitinterval(new_val: int, /) -> None: ...

mypy/typeshed/stdlib/asyncio/tools.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from collections.abc import Iterable
23
from enum import Enum
34
from typing import NamedTuple, SupportsIndex, type_check_only
@@ -37,5 +38,9 @@ class CycleFoundException(Exception):
3738
def get_all_awaited_by(pid: SupportsIndex) -> list[_AwaitedInfo]: ...
3839
def build_async_tree(result: Iterable[_AwaitedInfo], task_emoji: str = "(T)", cor_emoji: str = "") -> list[list[str]]: ...
3940
def build_task_table(result: Iterable[_AwaitedInfo]) -> list[list[int | str]]: ...
41+
42+
if sys.version_info >= (3, 14):
43+
def exit_with_permission_help_text() -> None: ...
44+
4045
def display_awaited_by_tasks_table(pid: SupportsIndex) -> None: ...
4146
def display_awaited_by_tasks_tree(pid: SupportsIndex) -> None: ...

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@ def __import__(
19171917
name: str,
19181918
globals: Mapping[str, object] | None = None,
19191919
locals: Mapping[str, object] | None = None,
1920-
fromlist: Sequence[str] = (),
1920+
fromlist: Sequence[str] | None = (),
19211921
level: int = 0,
19221922
) -> types.ModuleType: ...
19231923
def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ...

mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,30 @@ if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <
4545
def empty(self) -> bool: ...
4646
def full(self) -> bool: ...
4747
def qsize(self) -> int: ...
48-
def put(
49-
self,
50-
obj: object,
51-
timeout: SupportsIndex | None = None,
52-
*,
53-
unbounditems: _AnyUnbound | None = None,
54-
_delay: float = 0.01,
55-
) -> None: ...
48+
if sys.version_info >= (3, 14):
49+
def put(
50+
self,
51+
obj: object,
52+
block: bool = True,
53+
timeout: SupportsIndex | None = None,
54+
*,
55+
unbounditems: _AnyUnbound | None = None,
56+
_delay: float = 0.01,
57+
) -> None: ...
58+
else:
59+
def put(
60+
self,
61+
obj: object,
62+
timeout: SupportsIndex | None = None,
63+
*,
64+
unbounditems: _AnyUnbound | None = None,
65+
_delay: float = 0.01,
66+
) -> None: ...
67+
5668
def put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ...
57-
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
69+
if sys.version_info >= (3, 14):
70+
def get(self, block: bool = True, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
71+
else:
72+
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
73+
5874
def get_nowait(self) -> object: ...

mypy/typeshed/stdlib/configparser.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ class RawConfigParser(_Parser):
258258
) -> None: ...
259259

260260
def __len__(self) -> int: ...
261-
def __getitem__(self, key: str) -> SectionProxy: ...
262-
def __setitem__(self, key: str, value: _Section) -> None: ...
263-
def __delitem__(self, key: str) -> None: ...
261+
def __getitem__(self, key: _SectionName) -> SectionProxy: ...
262+
def __setitem__(self, key: _SectionName, value: _Section) -> None: ...
263+
def __delitem__(self, key: _SectionName) -> None: ...
264264
def __iter__(self) -> Iterator[str]: ...
265265
def __contains__(self, key: object) -> bool: ...
266266
def defaults(self) -> _Section: ...

mypy/typeshed/stdlib/copy.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import sys
22
from typing import Any, Protocol, TypeVar, type_check_only
3-
from typing_extensions import Self
43

54
__all__ = ["Error", "copy", "deepcopy"]
65

76
_T = TypeVar("_T")
8-
_SR = TypeVar("_SR", bound=_SupportsReplace)
7+
_RT_co = TypeVar("_RT_co", covariant=True)
98

109
@type_check_only
11-
class _SupportsReplace(Protocol):
12-
# In reality doesn't support args, but there's no other great way to express this.
13-
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
10+
class _SupportsReplace(Protocol[_RT_co]):
11+
# In reality doesn't support args, but there's no great way to express this.
12+
def __replace__(self, /, *_: Any, **changes: Any) -> _RT_co: ...
1413

1514
# None in CPython but non-None in Jython
1615
PyStringMap: Any
@@ -21,7 +20,8 @@ def copy(x: _T) -> _T: ...
2120

2221
if sys.version_info >= (3, 13):
2322
__all__ += ["replace"]
24-
def replace(obj: _SR, /, **changes: Any) -> _SR: ...
23+
# The types accepted by `**changes` match those of `obj.__replace__`.
24+
def replace(obj: _SupportsReplace[_RT_co], /, **changes: Any) -> _RT_co: ...
2525

2626
class Error(Exception): ...
2727

mypy/typeshed/stdlib/curses/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ _T = TypeVar("_T")
1414
_P = ParamSpec("_P")
1515

1616
# available after calling `curses.initscr()`
17-
LINES: Final[int]
18-
COLS: Final[int]
17+
# not `Final` as it can change during the terminal resize:
18+
LINES: int
19+
COLS: int
1920

2021
# available after calling `curses.start_color()`
2122
COLORS: Final[int]

mypy/typeshed/stdlib/dbm/sqlite3.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ class _Database(MutableMapping[bytes, bytes]):
2626
def __enter__(self) -> Self: ...
2727
def __exit__(self, *args: Unused) -> None: ...
2828

29-
def open(filename: StrOrBytesPath, /, flag: Literal["r", "w,", "c", "n"] = "r", mode: int = 0o666) -> _Database: ...
29+
def open(filename: StrOrBytesPath, /, flag: Literal["r", "w", "c", "n"] = "r", mode: int = 0o666) -> _Database: ...

0 commit comments

Comments
 (0)