Skip to content

Commit 5161ac2

Browse files
github-actions[bot]hauntsaninjaAlexWaygood
authored
Sync typeshed (#17124)
Source commit: python/typeshed@7c8e82f Co-authored-by: mypybot <> Co-authored-by: Shantanu <[email protected]> Co-authored-by: AlexWaygood <[email protected]>
1 parent e2fc1f2 commit 5161ac2

File tree

17 files changed

+795
-730
lines changed

17 files changed

+795
-730
lines changed

mypy/typeshed/stdlib/_curses.pyi

+549-542
Large diffs are not rendered by default.

mypy/typeshed/stdlib/asyncio/streams.pyi

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import ssl
22
import sys
3-
from _typeshed import StrPath
4-
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
5-
from typing import Any, SupportsIndex
3+
from _typeshed import ReadableBuffer, StrPath
4+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence, Sized
5+
from typing import Any, Protocol, SupportsIndex
66
from typing_extensions import Self, TypeAlias
77

88
from . import events, protocols, transports
@@ -23,6 +23,8 @@ else:
2323

2424
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
2525

26+
class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ...
27+
2628
if sys.version_info >= (3, 10):
2729
async def open_connection(
2830
host: str | None = None,
@@ -140,8 +142,11 @@ class StreamReader(AsyncIterator[bytes]):
140142
def at_eof(self) -> bool: ...
141143
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
142144
async def readline(self) -> bytes: ...
143-
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
144-
async def readuntil(self, separator: bytes | bytearray | memoryview = b"\n") -> bytes: ...
145+
if sys.version_info >= (3, 13):
146+
async def readuntil(self, separator: _ReaduntilBuffer | tuple[_ReaduntilBuffer, ...] = b"\n") -> bytes: ...
147+
else:
148+
async def readuntil(self, separator: _ReaduntilBuffer = b"\n") -> bytes: ...
149+
145150
async def read(self, n: int = -1) -> bytes: ...
146151
async def readexactly(self, n: int) -> bytes: ...
147152
def __aiter__(self) -> Self: ...
+14-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import sys
1+
from _curses import *
2+
from _curses import _CursesWindow as _CursesWindow
23
from collections.abc import Callable
34
from typing import TypeVar
45
from typing_extensions import Concatenate, ParamSpec
56

6-
if sys.platform != "win32":
7-
from _curses import *
8-
from _curses import _CursesWindow as _CursesWindow
7+
# NOTE: The _curses module is ordinarily only available on Unix, but the
8+
# windows-curses package makes it available on Windows as well with the same
9+
# contents.
910

10-
_T = TypeVar("_T")
11-
_P = ParamSpec("_P")
11+
_T = TypeVar("_T")
12+
_P = ParamSpec("_P")
1213

13-
# available after calling `curses.initscr()`
14-
LINES: int
15-
COLS: int
14+
# available after calling `curses.initscr()`
15+
LINES: int
16+
COLS: int
1617

17-
# available after calling `curses.start_color()`
18-
COLORS: int
19-
COLOR_PAIRS: int
18+
# available after calling `curses.start_color()`
19+
COLORS: int
20+
COLOR_PAIRS: int
2021

21-
def wrapper(func: Callable[Concatenate[_CursesWindow, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...
22+
def wrapper(func: Callable[Concatenate[_CursesWindow, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...

mypy/typeshed/stdlib/curses/ascii.pyi

+58-59
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,62 @@
1-
import sys
21
from typing import TypeVar
32

4-
if sys.platform != "win32":
5-
_CharT = TypeVar("_CharT", str, int)
3+
_CharT = TypeVar("_CharT", str, int)
64

7-
NUL: int
8-
SOH: int
9-
STX: int
10-
ETX: int
11-
EOT: int
12-
ENQ: int
13-
ACK: int
14-
BEL: int
15-
BS: int
16-
TAB: int
17-
HT: int
18-
LF: int
19-
NL: int
20-
VT: int
21-
FF: int
22-
CR: int
23-
SO: int
24-
SI: int
25-
DLE: int
26-
DC1: int
27-
DC2: int
28-
DC3: int
29-
DC4: int
30-
NAK: int
31-
SYN: int
32-
ETB: int
33-
CAN: int
34-
EM: int
35-
SUB: int
36-
ESC: int
37-
FS: int
38-
GS: int
39-
RS: int
40-
US: int
41-
SP: int
42-
DEL: int
5+
NUL: int
6+
SOH: int
7+
STX: int
8+
ETX: int
9+
EOT: int
10+
ENQ: int
11+
ACK: int
12+
BEL: int
13+
BS: int
14+
TAB: int
15+
HT: int
16+
LF: int
17+
NL: int
18+
VT: int
19+
FF: int
20+
CR: int
21+
SO: int
22+
SI: int
23+
DLE: int
24+
DC1: int
25+
DC2: int
26+
DC3: int
27+
DC4: int
28+
NAK: int
29+
SYN: int
30+
ETB: int
31+
CAN: int
32+
EM: int
33+
SUB: int
34+
ESC: int
35+
FS: int
36+
GS: int
37+
RS: int
38+
US: int
39+
SP: int
40+
DEL: int
4341

44-
controlnames: list[int]
45-
def isalnum(c: str | int) -> bool: ...
46-
def isalpha(c: str | int) -> bool: ...
47-
def isascii(c: str | int) -> bool: ...
48-
def isblank(c: str | int) -> bool: ...
49-
def iscntrl(c: str | int) -> bool: ...
50-
def isdigit(c: str | int) -> bool: ...
51-
def isgraph(c: str | int) -> bool: ...
52-
def islower(c: str | int) -> bool: ...
53-
def isprint(c: str | int) -> bool: ...
54-
def ispunct(c: str | int) -> bool: ...
55-
def isspace(c: str | int) -> bool: ...
56-
def isupper(c: str | int) -> bool: ...
57-
def isxdigit(c: str | int) -> bool: ...
58-
def isctrl(c: str | int) -> bool: ...
59-
def ismeta(c: str | int) -> bool: ...
60-
def ascii(c: _CharT) -> _CharT: ...
61-
def ctrl(c: _CharT) -> _CharT: ...
62-
def alt(c: _CharT) -> _CharT: ...
63-
def unctrl(c: str | int) -> str: ...
42+
controlnames: list[int]
43+
44+
def isalnum(c: str | int) -> bool: ...
45+
def isalpha(c: str | int) -> bool: ...
46+
def isascii(c: str | int) -> bool: ...
47+
def isblank(c: str | int) -> bool: ...
48+
def iscntrl(c: str | int) -> bool: ...
49+
def isdigit(c: str | int) -> bool: ...
50+
def isgraph(c: str | int) -> bool: ...
51+
def islower(c: str | int) -> bool: ...
52+
def isprint(c: str | int) -> bool: ...
53+
def ispunct(c: str | int) -> bool: ...
54+
def isspace(c: str | int) -> bool: ...
55+
def isupper(c: str | int) -> bool: ...
56+
def isxdigit(c: str | int) -> bool: ...
57+
def isctrl(c: str | int) -> bool: ...
58+
def ismeta(c: str | int) -> bool: ...
59+
def ascii(c: _CharT) -> _CharT: ...
60+
def ctrl(c: _CharT) -> _CharT: ...
61+
def alt(c: _CharT) -> _CharT: ...
62+
def unctrl(c: str | int) -> str: ...
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
import sys
2-
3-
if sys.platform != "win32":
4-
def has_key(ch: int | str) -> bool: ...
1+
def has_key(ch: int | str) -> bool: ...

mypy/typeshed/stdlib/curses/panel.pyi

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
import sys
1+
from _curses import _CursesWindow
22

3-
if sys.platform != "win32":
4-
from _curses import _CursesWindow
3+
version: str
54

6-
version: str
5+
class _Curses_Panel: # type is <class '_curses_panel.curses panel'> (note the space in the class name)
6+
def above(self) -> _Curses_Panel: ...
7+
def below(self) -> _Curses_Panel: ...
8+
def bottom(self) -> None: ...
9+
def hidden(self) -> bool: ...
10+
def hide(self) -> None: ...
11+
def move(self, y: int, x: int) -> None: ...
12+
def replace(self, win: _CursesWindow) -> None: ...
13+
def set_userptr(self, obj: object) -> None: ...
14+
def show(self) -> None: ...
15+
def top(self) -> None: ...
16+
def userptr(self) -> object: ...
17+
def window(self) -> _CursesWindow: ...
718

8-
class _Curses_Panel: # type is <class '_curses_panel.curses panel'> (note the space in the class name)
9-
def above(self) -> _Curses_Panel: ...
10-
def below(self) -> _Curses_Panel: ...
11-
def bottom(self) -> None: ...
12-
def hidden(self) -> bool: ...
13-
def hide(self) -> None: ...
14-
def move(self, y: int, x: int) -> None: ...
15-
def replace(self, win: _CursesWindow) -> None: ...
16-
def set_userptr(self, obj: object) -> None: ...
17-
def show(self) -> None: ...
18-
def top(self) -> None: ...
19-
def userptr(self) -> object: ...
20-
def window(self) -> _CursesWindow: ...
21-
22-
def bottom_panel() -> _Curses_Panel: ...
23-
def new_panel(win: _CursesWindow, /) -> _Curses_Panel: ...
24-
def top_panel() -> _Curses_Panel: ...
25-
def update_panels() -> _Curses_Panel: ...
19+
def bottom_panel() -> _Curses_Panel: ...
20+
def new_panel(win: _CursesWindow, /) -> _Curses_Panel: ...
21+
def top_panel() -> _Curses_Panel: ...
22+
def update_panels() -> _Curses_Panel: ...
+8-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import sys
1+
from _curses import _CursesWindow
22
from collections.abc import Callable
33

4-
if sys.platform != "win32":
5-
from _curses import _CursesWindow
6-
def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
4+
def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
75

8-
class Textbox:
9-
stripspaces: bool
10-
def __init__(self, win: _CursesWindow, insert_mode: bool = False) -> None: ...
11-
def edit(self, validate: Callable[[int], int] | None = None) -> str: ...
12-
def do_command(self, ch: str | int) -> None: ...
13-
def gather(self) -> str: ...
6+
class Textbox:
7+
stripspaces: bool
8+
def __init__(self, win: _CursesWindow, insert_mode: bool = False) -> None: ...
9+
def edit(self, validate: Callable[[int], int] | None = None) -> str: ...
10+
def do_command(self, ch: str | int) -> None: ...
11+
def gather(self) -> str: ...

mypy/typeshed/stdlib/importlib/resources/simple.pyi

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import abc
22
import sys
3-
from _typeshed import Incomplete, OpenBinaryMode, OpenTextMode, Unused
43
from collections.abc import Iterator
54
from io import TextIOWrapper
65
from typing import IO, Any, BinaryIO, Literal, NoReturn, overload
@@ -28,11 +27,19 @@ if sys.version_info >= (3, 11):
2827
def is_file(self) -> Literal[True]: ...
2928
def is_dir(self) -> Literal[False]: ...
3029
@overload
31-
def open(self, mode: OpenTextMode = "r", *args, **kwargs) -> TextIOWrapper: ...
30+
def open(
31+
self,
32+
mode: Literal["r"] = "r",
33+
encoding: str | None = None,
34+
errors: str | None = None,
35+
newline: str | None = None,
36+
line_buffering: bool = False,
37+
write_through: bool = False,
38+
) -> TextIOWrapper: ...
3239
@overload
33-
def open(self, mode: OpenBinaryMode, *args: Unused, **kwargs: Unused) -> BinaryIO: ...
40+
def open(self, mode: Literal["rb"]) -> BinaryIO: ...
3441
@overload
35-
def open(self, mode: str, *args: Incomplete, **kwargs) -> IO[Any]: ...
42+
def open(self, mode: str) -> IO[Any]: ...
3643
def joinpath(self, name: Never) -> NoReturn: ... # type: ignore[override]
3744

3845
class ResourceContainer(Traversable, metaclass=abc.ABCMeta):

mypy/typeshed/stdlib/io.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d
179179
def __init__(
180180
self,
181181
buffer: _WrappedBuffer,
182-
encoding: str | None = ...,
183-
errors: str | None = ...,
184-
newline: str | None = ...,
185-
line_buffering: bool = ...,
186-
write_through: bool = ...,
182+
encoding: str | None = None,
183+
errors: str | None = None,
184+
newline: str | None = None,
185+
line_buffering: bool = False,
186+
write_through: bool = False,
187187
) -> None: ...
188188
# Equals the "buffer" argument passed in to the constructor.
189189
@property

mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ __all__ = ["ensure_running", "register", "unregister"]
66
class ResourceTracker:
77
def getfd(self) -> int | None: ...
88
def ensure_running(self) -> None: ...
9-
def register(self, name: Sized, rtype) -> None: ...
10-
def unregister(self, name: Sized, rtype) -> None: ...
9+
def register(self, name: Sized, rtype: str) -> None: ...
10+
def unregister(self, name: Sized, rtype: str) -> None: ...
1111

1212
_resource_tracker: ResourceTracker
1313
ensure_running = _resource_tracker.ensure_running

mypy/typeshed/stdlib/multiprocessing/util.pyi

+25-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import threading
22
from _typeshed import ConvertibleToInt, Incomplete, Unused
33
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
44
from logging import Logger, _Level as _LoggingLevel
5-
from typing import Any
5+
from typing import Any, Generic, TypeVar, overload
66

77
__all__ = [
88
"sub_debug",
@@ -22,6 +22,9 @@ __all__ = [
2222
"SUBWARNING",
2323
]
2424

25+
_T = TypeVar("_T")
26+
_R_co = TypeVar("_R_co", default=Any, covariant=True)
27+
2528
NOTSET: int
2629
SUBDEBUG: int
2730
DEBUG: int
@@ -42,13 +45,29 @@ def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...
4245
abstract_sockets_supported: bool
4346

4447
def get_temp_dir() -> str: ...
45-
def register_after_fork(obj, func: Callable[[Incomplete], object]) -> None: ...
48+
def register_after_fork(obj: _T, func: Callable[[_T], object]) -> None: ...
4649

47-
class Finalize:
50+
class Finalize(Generic[_R_co]):
51+
# "args" and "kwargs" are passed as arguments to "callback".
52+
@overload
53+
def __init__(
54+
self,
55+
obj: None,
56+
callback: Callable[..., _R_co],
57+
*,
58+
args: Sequence[Any] = (),
59+
kwargs: Mapping[str, Any] | None = None,
60+
exitpriority: int,
61+
) -> None: ...
62+
@overload
63+
def __init__(
64+
self, obj: None, callback: Callable[..., _R_co], args: Sequence[Any], kwargs: Mapping[str, Any] | None, exitpriority: int
65+
) -> None: ...
66+
@overload
4867
def __init__(
4968
self,
50-
obj: Incomplete | None,
51-
callback: Callable[..., Incomplete],
69+
obj: Any,
70+
callback: Callable[..., _R_co],
5271
args: Sequence[Any] = (),
5372
kwargs: Mapping[str, Any] | None = None,
5473
exitpriority: int | None = None,
@@ -59,7 +78,7 @@ class Finalize:
5978
_finalizer_registry: MutableMapping[Incomplete, Incomplete] = {},
6079
sub_debug: Callable[..., object] = ...,
6180
getpid: Callable[[], int] = ...,
62-
): ...
81+
) -> _R_co: ...
6382
def cancel(self) -> None: ...
6483
def still_active(self) -> bool: ...
6584

0 commit comments

Comments
 (0)