Skip to content

Commit 69c774e

Browse files
Sync typeshed (#15055)
Source commit: python/typeshed@b0ed50e
1 parent 8f94d9a commit 69c774e

File tree

8 files changed

+96
-55
lines changed

8 files changed

+96
-55
lines changed

Diff for: mypy/typeshed/stdlib/asyncio/base_events.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ class BaseEventLoop(AbstractEventLoop):
417417
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
418418
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
419419
if sys.version_info >= (3, 11):
420-
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
421-
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> int: ...
422-
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> None: ...
420+
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
421+
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> tuple[int, _RetAddress]: ...
422+
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> int: ...
423423
# Signal handling.
424424
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
425425
def remove_signal_handler(self, sig: int) -> bool: ...

Diff for: mypy/typeshed/stdlib/asyncio/events.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,11 @@ class AbstractEventLoop:
569569
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
570570
if sys.version_info >= (3, 11):
571571
@abstractmethod
572-
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
572+
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
573573
@abstractmethod
574-
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> int: ...
574+
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> tuple[int, _RetAddress]: ...
575575
@abstractmethod
576-
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> None: ...
576+
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> int: ...
577577
# Signal handling.
578578
@abstractmethod
579579
def add_signal_handler(self, sig: int, callback: Callable[..., object], *args: Any) -> None: ...

Diff for: mypy/typeshed/stdlib/dataclasses.pyi

+21-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,27 @@ class InitVar(Generic[_T], metaclass=_InitVarMeta):
247247
@overload
248248
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ...
249249

250-
if sys.version_info >= (3, 11):
250+
if sys.version_info >= (3, 12):
251+
def make_dataclass(
252+
cls_name: str,
253+
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
254+
*,
255+
bases: tuple[type, ...] = (),
256+
namespace: dict[str, Any] | None = None,
257+
init: bool = True,
258+
repr: bool = True,
259+
eq: bool = True,
260+
order: bool = False,
261+
unsafe_hash: bool = False,
262+
frozen: bool = False,
263+
match_args: bool = True,
264+
kw_only: bool = False,
265+
slots: bool = False,
266+
weakref_slot: bool = False,
267+
module: str | None = None,
268+
) -> type: ...
269+
270+
elif sys.version_info >= (3, 11):
251271
def make_dataclass(
252272
cls_name: str,
253273
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],

Diff for: mypy/typeshed/stdlib/pathlib.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ class Path(PurePath):
173173
def resolve(self, strict: bool = False) -> Self: ...
174174
def rglob(self, pattern: str) -> Generator[Self, None, None]: ...
175175
def rmdir(self) -> None: ...
176-
def symlink_to(self, target: str | Path, target_is_directory: bool = False) -> None: ...
176+
def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ...
177177
if sys.version_info >= (3, 10):
178-
def hardlink_to(self, target: str | Path) -> None: ...
178+
def hardlink_to(self, target: StrOrBytesPath) -> None: ...
179179

180180
def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: ...
181181
if sys.version_info >= (3, 8):

Diff for: mypy/typeshed/stdlib/sys.pyi

+14
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ class _int_info(structseq[int], tuple[int, int, int, int]):
201201
@property
202202
def str_digits_check_threshold(self) -> int: ...
203203

204+
_ThreadInfoName: TypeAlias = Literal["nt", "pthread", "pthread-stubs", "solaris"]
205+
_ThreadInfoLock: TypeAlias = Literal["semaphore", "mutex+cond"] | None
206+
207+
@final
208+
class _thread_info(_UninstantiableStructseq, tuple[_ThreadInfoName, _ThreadInfoLock, str | None]):
209+
@property
210+
def name(self) -> _ThreadInfoName: ...
211+
@property
212+
def lock(self) -> _ThreadInfoLock: ...
213+
@property
214+
def version(self) -> str | None: ...
215+
216+
thread_info: _thread_info
217+
204218
@final
205219
class _version_info(_UninstantiableStructseq, tuple[int, int, int, str, int]):
206220
@property

Diff for: mypy/typeshed/stdlib/tkinter/__init__.pyi

+36-36
Original file line numberDiff line numberDiff line change
@@ -1234,16 +1234,16 @@ class Canvas(Widget, XView, YView):
12341234
__x1: float,
12351235
__y1: float,
12361236
*,
1237-
activedash: str | list[int] | tuple[int, ...] = ...,
1237+
activedash: str | int | list[int] | tuple[int, ...] = ...,
12381238
activefill: str = ...,
12391239
activestipple: str = ...,
12401240
activewidth: _ScreenUnits = ...,
12411241
arrow: Literal["first", "last", "both"] = ...,
12421242
arrowshape: tuple[float, float, float] = ...,
12431243
capstyle: Literal["round", "projecting", "butt"] = ...,
1244-
dash: str | list[int] | tuple[int, ...] = ...,
1244+
dash: str | int | list[int] | tuple[int, ...] = ...,
12451245
dashoffset: _ScreenUnits = ...,
1246-
disableddash: str | list[int] | tuple[int, ...] = ...,
1246+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
12471247
disabledfill: str = ...,
12481248
disabledstipple: str = ...,
12491249
disabledwidth: _ScreenUnits = ...,
@@ -1263,16 +1263,16 @@ class Canvas(Widget, XView, YView):
12631263
__xy_pair_0: tuple[float, float],
12641264
__xy_pair_1: tuple[float, float],
12651265
*,
1266-
activedash: str | list[int] | tuple[int, ...] = ...,
1266+
activedash: str | int | list[int] | tuple[int, ...] = ...,
12671267
activefill: str = ...,
12681268
activestipple: str = ...,
12691269
activewidth: _ScreenUnits = ...,
12701270
arrow: Literal["first", "last", "both"] = ...,
12711271
arrowshape: tuple[float, float, float] = ...,
12721272
capstyle: Literal["round", "projecting", "butt"] = ...,
1273-
dash: str | list[int] | tuple[int, ...] = ...,
1273+
dash: str | int | list[int] | tuple[int, ...] = ...,
12741274
dashoffset: _ScreenUnits = ...,
1275-
disableddash: str | list[int] | tuple[int, ...] = ...,
1275+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
12761276
disabledfill: str = ...,
12771277
disabledstipple: str = ...,
12781278
disabledwidth: _ScreenUnits = ...,
@@ -1298,16 +1298,16 @@ class Canvas(Widget, XView, YView):
12981298
| list[tuple[float, float]]
12991299
),
13001300
*,
1301-
activedash: str | list[int] | tuple[int, ...] = ...,
1301+
activedash: str | int | list[int] | tuple[int, ...] = ...,
13021302
activefill: str = ...,
13031303
activestipple: str = ...,
13041304
activewidth: _ScreenUnits = ...,
13051305
arrow: Literal["first", "last", "both"] = ...,
13061306
arrowshape: tuple[float, float, float] = ...,
13071307
capstyle: Literal["round", "projecting", "butt"] = ...,
1308-
dash: str | list[int] | tuple[int, ...] = ...,
1308+
dash: str | int | list[int] | tuple[int, ...] = ...,
13091309
dashoffset: _ScreenUnits = ...,
1310-
disableddash: str | list[int] | tuple[int, ...] = ...,
1310+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
13111311
disabledfill: str = ...,
13121312
disabledstipple: str = ...,
13131313
disabledwidth: _ScreenUnits = ...,
@@ -1329,15 +1329,15 @@ class Canvas(Widget, XView, YView):
13291329
__x1: float,
13301330
__y1: float,
13311331
*,
1332-
activedash: str | list[int] | tuple[int, ...] = ...,
1332+
activedash: str | int | list[int] | tuple[int, ...] = ...,
13331333
activefill: str = ...,
13341334
activeoutline: str = ...,
13351335
activeoutlinestipple: str = ...,
13361336
activestipple: str = ...,
13371337
activewidth: _ScreenUnits = ...,
1338-
dash: str | list[int] | tuple[int, ...] = ...,
1338+
dash: str | int | list[int] | tuple[int, ...] = ...,
13391339
dashoffset: _ScreenUnits = ...,
1340-
disableddash: str | list[int] | tuple[int, ...] = ...,
1340+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
13411341
disabledfill: str = ...,
13421342
disabledoutline: str = ...,
13431343
disabledoutlinestipple: str = ...,
@@ -1359,15 +1359,15 @@ class Canvas(Widget, XView, YView):
13591359
__xy_pair_0: tuple[float, float],
13601360
__xy_pair_1: tuple[float, float],
13611361
*,
1362-
activedash: str | list[int] | tuple[int, ...] = ...,
1362+
activedash: str | int | list[int] | tuple[int, ...] = ...,
13631363
activefill: str = ...,
13641364
activeoutline: str = ...,
13651365
activeoutlinestipple: str = ...,
13661366
activestipple: str = ...,
13671367
activewidth: _ScreenUnits = ...,
1368-
dash: str | list[int] | tuple[int, ...] = ...,
1368+
dash: str | int | list[int] | tuple[int, ...] = ...,
13691369
dashoffset: _ScreenUnits = ...,
1370-
disableddash: str | list[int] | tuple[int, ...] = ...,
1370+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
13711371
disabledfill: str = ...,
13721372
disabledoutline: str = ...,
13731373
disabledoutlinestipple: str = ...,
@@ -1395,15 +1395,15 @@ class Canvas(Widget, XView, YView):
13951395
| list[tuple[float, float]]
13961396
),
13971397
*,
1398-
activedash: str | list[int] | tuple[int, ...] = ...,
1398+
activedash: str | int | list[int] | tuple[int, ...] = ...,
13991399
activefill: str = ...,
14001400
activeoutline: str = ...,
14011401
activeoutlinestipple: str = ...,
14021402
activestipple: str = ...,
14031403
activewidth: _ScreenUnits = ...,
1404-
dash: str | list[int] | tuple[int, ...] = ...,
1404+
dash: str | int | list[int] | tuple[int, ...] = ...,
14051405
dashoffset: _ScreenUnits = ...,
1406-
disableddash: str | list[int] | tuple[int, ...] = ...,
1406+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
14071407
disabledfill: str = ...,
14081408
disabledoutline: str = ...,
14091409
disabledoutlinestipple: str = ...,
@@ -1427,15 +1427,15 @@ class Canvas(Widget, XView, YView):
14271427
__x1: float,
14281428
__y1: float,
14291429
*xy_pairs: float,
1430-
activedash: str | list[int] | tuple[int, ...] = ...,
1430+
activedash: str | int | list[int] | tuple[int, ...] = ...,
14311431
activefill: str = ...,
14321432
activeoutline: str = ...,
14331433
activeoutlinestipple: str = ...,
14341434
activestipple: str = ...,
14351435
activewidth: _ScreenUnits = ...,
1436-
dash: str | list[int] | tuple[int, ...] = ...,
1436+
dash: str | int | list[int] | tuple[int, ...] = ...,
14371437
dashoffset: _ScreenUnits = ...,
1438-
disableddash: str | list[int] | tuple[int, ...] = ...,
1438+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
14391439
disabledfill: str = ...,
14401440
disabledoutline: str = ...,
14411441
disabledoutlinestipple: str = ...,
@@ -1460,15 +1460,15 @@ class Canvas(Widget, XView, YView):
14601460
__xy_pair_0: tuple[float, float],
14611461
__xy_pair_1: tuple[float, float],
14621462
*xy_pairs: tuple[float, float],
1463-
activedash: str | list[int] | tuple[int, ...] = ...,
1463+
activedash: str | int | list[int] | tuple[int, ...] = ...,
14641464
activefill: str = ...,
14651465
activeoutline: str = ...,
14661466
activeoutlinestipple: str = ...,
14671467
activestipple: str = ...,
14681468
activewidth: _ScreenUnits = ...,
1469-
dash: str | list[int] | tuple[int, ...] = ...,
1469+
dash: str | int | list[int] | tuple[int, ...] = ...,
14701470
dashoffset: _ScreenUnits = ...,
1471-
disableddash: str | list[int] | tuple[int, ...] = ...,
1471+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
14721472
disabledfill: str = ...,
14731473
disabledoutline: str = ...,
14741474
disabledoutlinestipple: str = ...,
@@ -1499,15 +1499,15 @@ class Canvas(Widget, XView, YView):
14991499
| list[tuple[float, float]]
15001500
),
15011501
*,
1502-
activedash: str | list[int] | tuple[int, ...] = ...,
1502+
activedash: str | int | list[int] | tuple[int, ...] = ...,
15031503
activefill: str = ...,
15041504
activeoutline: str = ...,
15051505
activeoutlinestipple: str = ...,
15061506
activestipple: str = ...,
15071507
activewidth: _ScreenUnits = ...,
1508-
dash: str | list[int] | tuple[int, ...] = ...,
1508+
dash: str | int | list[int] | tuple[int, ...] = ...,
15091509
dashoffset: _ScreenUnits = ...,
1510-
disableddash: str | list[int] | tuple[int, ...] = ...,
1510+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
15111511
disabledfill: str = ...,
15121512
disabledoutline: str = ...,
15131513
disabledoutlinestipple: str = ...,
@@ -1534,15 +1534,15 @@ class Canvas(Widget, XView, YView):
15341534
__x1: float,
15351535
__y1: float,
15361536
*,
1537-
activedash: str | list[int] | tuple[int, ...] = ...,
1537+
activedash: str | int | list[int] | tuple[int, ...] = ...,
15381538
activefill: str = ...,
15391539
activeoutline: str = ...,
15401540
activeoutlinestipple: str = ...,
15411541
activestipple: str = ...,
15421542
activewidth: _ScreenUnits = ...,
1543-
dash: str | list[int] | tuple[int, ...] = ...,
1543+
dash: str | int | list[int] | tuple[int, ...] = ...,
15441544
dashoffset: _ScreenUnits = ...,
1545-
disableddash: str | list[int] | tuple[int, ...] = ...,
1545+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
15461546
disabledfill: str = ...,
15471547
disabledoutline: str = ...,
15481548
disabledoutlinestipple: str = ...,
@@ -1564,15 +1564,15 @@ class Canvas(Widget, XView, YView):
15641564
__xy_pair_0: tuple[float, float],
15651565
__xy_pair_1: tuple[float, float],
15661566
*,
1567-
activedash: str | list[int] | tuple[int, ...] = ...,
1567+
activedash: str | int | list[int] | tuple[int, ...] = ...,
15681568
activefill: str = ...,
15691569
activeoutline: str = ...,
15701570
activeoutlinestipple: str = ...,
15711571
activestipple: str = ...,
15721572
activewidth: _ScreenUnits = ...,
1573-
dash: str | list[int] | tuple[int, ...] = ...,
1573+
dash: str | int | list[int] | tuple[int, ...] = ...,
15741574
dashoffset: _ScreenUnits = ...,
1575-
disableddash: str | list[int] | tuple[int, ...] = ...,
1575+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
15761576
disabledfill: str = ...,
15771577
disabledoutline: str = ...,
15781578
disabledoutlinestipple: str = ...,
@@ -1600,15 +1600,15 @@ class Canvas(Widget, XView, YView):
16001600
| list[tuple[float, float]]
16011601
),
16021602
*,
1603-
activedash: str | list[int] | tuple[int, ...] = ...,
1603+
activedash: str | int | list[int] | tuple[int, ...] = ...,
16041604
activefill: str = ...,
16051605
activeoutline: str = ...,
16061606
activeoutlinestipple: str = ...,
16071607
activestipple: str = ...,
16081608
activewidth: _ScreenUnits = ...,
1609-
dash: str | list[int] | tuple[int, ...] = ...,
1609+
dash: str | int | list[int] | tuple[int, ...] = ...,
16101610
dashoffset: _ScreenUnits = ...,
1611-
disableddash: str | list[int] | tuple[int, ...] = ...,
1611+
disableddash: str | int | list[int] | tuple[int, ...] = ...,
16121612
disabledfill: str = ...,
16131613
disabledoutline: str = ...,
16141614
disabledoutlinestipple: str = ...,

Diff for: mypy/typeshed/stdlib/urllib/parse.pyi

+7-6
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,15 @@ else:
196196
url: bytes | bytearray | None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True
197197
) -> SplitResultBytes: ...
198198

199+
# Requires an iterable of length 6
199200
@overload
200-
def urlunparse(
201-
components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None]
202-
) -> AnyStr: ...
201+
def urlunparse(components: Iterable[None]) -> Literal[b""]: ...
203202
@overload
204-
def urlunparse(components: Sequence[AnyStr | None]) -> AnyStr: ...
203+
def urlunparse(components: Iterable[AnyStr | None]) -> AnyStr: ...
204+
205+
# Requires an iterable of length 5
205206
@overload
206-
def urlunsplit(components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None]) -> AnyStr: ...
207+
def urlunsplit(components: Iterable[None]) -> Literal[b""]: ...
207208
@overload
208-
def urlunsplit(components: Sequence[AnyStr | None]) -> AnyStr: ...
209+
def urlunsplit(components: Iterable[AnyStr | None]) -> AnyStr: ...
209210
def unwrap(url: str) -> str: ...

Diff for: mypy/typeshed/stdlib/zipfile.pyi

+10-4
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ class ZipInfo:
222222
def is_dir(self) -> bool: ...
223223
def FileHeader(self, zip64: bool | None = None) -> bytes: ...
224224

225-
class _PathOpenProtocol(Protocol):
226-
def __call__(self, mode: _ReadWriteMode = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
227-
228225
if sys.version_info >= (3, 8):
226+
if sys.version_info < (3, 9):
227+
class _PathOpenProtocol(Protocol):
228+
def __call__(self, mode: _ReadWriteMode = "r", pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
229+
229230
class Path:
230231
@property
231232
def name(self) -> str: ...
@@ -245,7 +246,12 @@ if sys.version_info >= (3, 8):
245246
def __init__(self, root: ZipFile | StrPath | IO[bytes], at: str = "") -> None: ...
246247
if sys.version_info >= (3, 9):
247248
def open(
248-
self, mode: _ReadWriteBinaryMode = "r", *args: Any, pwd: bytes | None = None, **kwargs: Any
249+
self,
250+
mode: _ReadWriteBinaryMode = "r",
251+
encoding: str | None = None,
252+
*args: Any,
253+
pwd: bytes | None = None,
254+
**kwargs: Any,
249255
) -> IO[bytes]: ...
250256
else:
251257
@property

0 commit comments

Comments
 (0)