Skip to content

Commit 8f3f594

Browse files
github-actions[bot]cdce8phauntsaninjailevkivskyiAlexWaygood
authored
Sync typeshed (#21852)
Sync typeshed Source commit: python/typeshed@6fba3ae Note that you will need to close and re-open the PR in order to trigger CI. --------- Co-authored-by: mypybot <> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com> Co-authored-by: hauntsaninja <hauntsaninja@gmail.com> Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
1 parent d6d7295 commit 8f3f594

52 files changed

Lines changed: 124 additions & 69 deletions

Some content is hidden

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

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ else:
5353
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
5454
# and `asyncio.Task.set_result()` always raises.
5555
@disjoint_base
56-
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments] # ty:ignore[invalid-generic-class]
56+
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments] # ty:ignore[invalid-generic-class] # pyrefly: ignore [invalid-variance]
5757
if sys.version_info >= (3, 12):
5858
def __init__(
5959
self,

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,8 @@ def Py_INCREF(o: _T, /) -> _T: ...
368368
def buffer_info(o: _CData | _CDataType | type[_CData | _CDataType], /) -> tuple[str, int, tuple[int, ...]]: ...
369369
def call_cdeclfunction(address: int, arguments: tuple[Any, ...], /) -> Any: ...
370370
def call_function(address: int, arguments: tuple[Any, ...], /) -> Any: ...
371+
372+
# dllist() is available on Linux and other platforms like NetBSD
373+
if sys.version_info >= (3, 14) and sys.platform != "win32" and sys.platform != "darwin":
374+
# Added in Python 3.14.7
375+
def dllist() -> list[str]: ...

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ class SupportsTrunc(Protocol):
168168

169169
# Mapping-like protocols
170170

171+
# The second and third overload could technically be combined, but splitting
172+
# them works better with some type checkers.
173+
class SupportsGet(Protocol[_KT_contra, _VT_co]): # type: ignore[misc] # Covariant type as parameter
174+
@overload
175+
def get(self, key: _KT_contra, /) -> _VT_co | None: ...
176+
@overload
177+
def get( # pyrefly: ignore[invalid-variance]
178+
self, key: _KT_contra, default: _VT_co, / # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
179+
) -> _VT_co: ...
180+
@overload
181+
def get(self, key: _KT_contra, default: _T, /) -> _VT_co | _T: ...
182+
171183
# stable
172184
class SupportsItems(Protocol[_KT_co, _VT_co]):
173185
def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ...
@@ -193,6 +205,8 @@ class SupportsItemAccess(Protocol[_KT_contra, _VT]):
193205
def __setitem__(self, key: _KT_contra, value: _VT, /) -> None: ...
194206
def __delitem__(self, key: _KT_contra, /) -> None: ...
195207

208+
# Path and file handling
209+
196210
StrPath: TypeAlias = str | PathLike[str] # stable
197211
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
198212
GenericPath: TypeAlias = AnyStr | PathLike[AnyStr]

mypy/typeshed/stdlib/_winapi.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,6 @@ if sys.platform == "win32":
314314
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
315315
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...
316316

317-
if sys.version_info >= (3, 15):
317+
if sys.version_info >= (3, 13):
318+
# Added in Python 3.13.15, 3.14.7
318319
def GetTickCount64() -> int: ...

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ class HelpFormatter:
324324
_current_indent: int
325325
_level: int
326326
_action_max_length: int
327-
_root_section: _Section
328-
_current_section: _Section
327+
_root_section: _Section # pyrefly: ignore [unknown-name]
328+
_current_section: _Section # pyrefly: ignore [unknown-name]
329329
_whitespace_matcher: Pattern[str]
330330
_long_break_matcher: Pattern[str]
331331

mypy/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class BaseEventLoop(AbstractEventLoop):
8383
# Future methods
8484
def create_future(self) -> Future[Any]: ...
8585
# Tasks methods
86-
if sys.version_info >= (3, 14):
86+
# `eager_start` is supported as an arbitrary kwarg starting in 3.13.3.
87+
if sys.version_info >= (3, 13):
8788
def create_task(
8889
self,
8990
coro: _CoroutineLike[_T],

mypy/typeshed/stdlib/asyncio/events.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ class AbstractEventLoop:
161161
@abstractmethod
162162
def create_future(self) -> Future[Any]: ...
163163
# Tasks methods
164-
if sys.version_info >= (3, 14):
164+
# `eager_start` is supported as an arbitrary kwarg starting in 3.13.3.
165+
if sys.version_info >= (3, 13):
165166
@abstractmethod
166167
def create_task(
167168
self,

mypy/typeshed/stdlib/collections/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,17 @@ class _OrderedDictValuesView(ValuesView[_VT_co]):
365365
# pyright doesn't have a specific error code for subclassing error!
366366
@final
367367
@type_check_only
368-
class _odict_keys(dict_keys[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class]
368+
class _odict_keys(dict_keys[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class] # pyrefly: ignore [invalid-inheritance]
369369
def __reversed__(self) -> Iterator[_KT_co]: ...
370370

371371
@final
372372
@type_check_only
373-
class _odict_items(dict_items[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class]
373+
class _odict_items(dict_items[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class] # pyrefly: ignore [invalid-inheritance]
374374
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
375375

376376
@final
377377
@type_check_only
378-
class _odict_values(dict_values[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class]
378+
class _odict_values(dict_values[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[subclass-of-final-class] # pyrefly: ignore [invalid-inheritance]
379379
def __reversed__(self) -> Iterator[_VT_co]: ...
380380

381381
@disjoint_base

mypy/typeshed/stdlib/concurrent/futures/process.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class _ExecutorManagerThread(Thread):
147147
def process_result_item(self, result_item: int | _ResultItem) -> None: ...
148148
def is_shutting_down(self) -> bool: ...
149149

150-
if sys.version_info >= (3, 15):
150+
if sys.version_info >= (3, 14):
151+
# bpe_message parameter added in 3.14.7
151152
def terminate_broken(self, cause: str, bpe_message: str | None = None) -> None: ...
152153
else:
153154
def terminate_broken(self, cause: str) -> None: ...

mypy/typeshed/stdlib/contextlib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _CM_EF = TypeVar("_CM_EF", bound=AbstractContextManager[Any, Any] | _ExitFunc)
4343
# At runtime it inherits from ABC and is not a Protocol, but it is on the
4444
# allowlist for use as a Protocol.
4545
@runtime_checkable
46-
class AbstractContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[invalid-protocol]
46+
class AbstractContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[invalid-protocol] # pyrefly: ignore [invalid-inheritance]
4747
__slots__ = ()
4848
def __enter__(self) -> _T_co: ...
4949
@abstractmethod
@@ -55,7 +55,7 @@ class AbstractContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[m
5555
# At runtime it inherits from ABC and is not a Protocol, but it is on the
5656
# allowlist for use as a Protocol.
5757
@runtime_checkable
58-
class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[invalid-protocol]
58+
class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # ty:ignore[invalid-protocol] # pyrefly: ignore [invalid-inheritance]
5959
__slots__ = ()
6060
async def __aenter__(self) -> _T_co: ...
6161
@abstractmethod

0 commit comments

Comments
 (0)