Skip to content

Commit 5d909f1

Browse files
koogorohauntsaninjaAlexWaygood
authored
Sync typeshed for 1.6 (#15918)
Use the sync-typeshed script to sync the latest typeshed before the 1.6 release. --------- Co-authored-by: Shantanu <[email protected]> Co-authored-by: AlexWaygood <[email protected]>
1 parent 5af7671 commit 5d909f1

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ Incomplete: TypeAlias = Any
3636
# To describe a function parameter that is unused and will work with anything.
3737
Unused: TypeAlias = object
3838

39+
# Used to mark arguments that default to a sentinel value. This prevents
40+
# stubtest from complaining about the default value not matching.
41+
#
42+
# def foo(x: int | None = sentinel) -> None: ...
43+
#
44+
# In cases where the sentinel object is exported and can be used by user code,
45+
# a construct like this is better:
46+
#
47+
# _SentinelType = NewType("_SentinelType", object)
48+
# sentinel: _SentinelType
49+
# def foo(x: int | None | _SentinelType = ...) -> None: ...
50+
sentinel = Any # noqa: Y026
51+
3952
# stable
4053
class IdentityFunction(Protocol):
4154
def __call__(self, __x: _T) -> _T: ...

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from _typeshed import sentinel
23
from collections.abc import Callable, Generator, Iterable, Sequence
34
from re import Pattern
45
from typing import IO, Any, Generic, NewType, NoReturn, Protocol, TypeVar, overload
@@ -334,7 +335,21 @@ class Action(_AttributeHolder):
334335
if sys.version_info >= (3, 9):
335336
def format_usage(self) -> str: ...
336337

337-
if sys.version_info >= (3, 9):
338+
if sys.version_info >= (3, 12):
339+
class BooleanOptionalAction(Action):
340+
def __init__(
341+
self,
342+
option_strings: Sequence[str],
343+
dest: str,
344+
default: _T | str | None = None,
345+
type: Callable[[str], _T] | FileType | None = sentinel, # noqa: Y011
346+
choices: Iterable[_T] | None = sentinel, # noqa: Y011
347+
required: bool = False,
348+
help: str | None = None,
349+
metavar: str | tuple[str, ...] | None = sentinel, # noqa: Y011
350+
) -> None: ...
351+
352+
elif sys.version_info >= (3, 9):
338353
class BooleanOptionalAction(Action):
339354
def __init__(
340355
self,

mypy/typeshed/stdlib/os/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ else:
912912
@property
913913
def si_code(self) -> int: ...
914914

915-
def waitid(__idtype: int, __ident: int, __options: int) -> waitid_result: ...
915+
def waitid(__idtype: int, __ident: int, __options: int) -> waitid_result | None: ...
916916

917917
def wait3(options: int) -> tuple[int, int, Any]: ...
918918
def wait4(pid: int, options: int) -> tuple[int, int, Any]: ...

mypy/typeshed/stdlib/ssl.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,15 @@ class SSLContext:
436436
server_side: bool = False,
437437
do_handshake_on_connect: bool = True,
438438
suppress_ragged_eofs: bool = True,
439-
server_hostname: str | None = None,
439+
server_hostname: str | bytes | None = None,
440440
session: SSLSession | None = None,
441441
) -> SSLSocket: ...
442442
def wrap_bio(
443443
self,
444444
incoming: MemoryBIO,
445445
outgoing: MemoryBIO,
446446
server_side: bool = False,
447-
server_hostname: str | None = None,
447+
server_hostname: str | bytes | None = None,
448448
session: SSLSession | None = None,
449449
) -> SSLObject: ...
450450
def session_stats(self) -> dict[str, int]: ...

0 commit comments

Comments
 (0)