Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Temporarily revert contextlib deprecation
  • Loading branch information
hauntsaninja authored and mypybot committed Apr 15, 2026
commit 196e129e6b2c66c1565d5f854c5076d5669b3dd1
15 changes: 1 addition & 14 deletions mypy/typeshed/stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from abc import ABC, abstractmethod
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator
from types import TracebackType
from typing import Any, Generic, Protocol, TypeVar, overload, runtime_checkable, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias, deprecated
from typing_extensions import ParamSpec, Self, TypeAlias

__all__ = [
"contextmanager",
Expand Down Expand Up @@ -86,12 +86,6 @@ class _GeneratorContextManager(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...

@overload
def contextmanager(func: Callable[_P, Generator[_T_co, None, object]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...
@overload
@deprecated(
"Annotating the return type as `-> Iterator[Foo]` with `@contextmanager` is deprecated. Use `-> Generator[Foo]` instead."
)
def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...

if sys.version_info >= (3, 10):
Expand All @@ -118,13 +112,6 @@ else:
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...

@overload
def asynccontextmanager(func: Callable[_P, AsyncGenerator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ...
@overload
@deprecated(
"Annotating the return type as `-> AsyncIterator[Foo]` with `@asynccontextmanager` is deprecated. "
"Use `-> AsyncGenerator[Foo]` instead."
)
def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ...
@type_check_only
class _SupportsClose(Protocol):
Expand Down
Loading