Skip to content

Allow to extend return types of functions decorated by ContextDecorator with None #14439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Increase LoB and improve comments
  • Loading branch information
bswck committed Jul 22, 2025
commit 6db7d8dd9ba6f7c7edf0080120d276f980a231df
5 changes: 3 additions & 2 deletions stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ _T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_io = TypeVar("_T_io", bound=IO[str] | None)
_ExitT_co = TypeVar("_ExitT_co", covariant=True, bound=bool | None, default=bool | None)
_SuppressedExcReturnT = TypeVar("_SuppressedExcReturnT", Never, None, default=Never)
_F = TypeVar("_F", bound=Callable[..., Any])
_G_co = TypeVar("_G_co", bound=Generator[Any, Any, Any] | AsyncGenerator[Any, Any], covariant=True)
_P = ParamSpec("_P")
Expand Down Expand Up @@ -66,9 +65,11 @@ class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ign
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
) -> _ExitT_co: ...

_SuppressedExcReturnT = TypeVar("_SuppressedExcReturnT", Never, None, default=Never)
# __exit__ can suppress exceptions by returning a true value.
# _SuppressedReturnT extends the decorated function's return type with
# - Never, if the decorating context manager never suppresses exceptions;
# - Never (default, has no effect on the return type),
# if the decorating context manager never suppresses exceptions;
# - None, if the decorating context manager may suppress exceptions.
# See #13512.
class ContextDecorator(Generic[_SuppressedExcReturnT]):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy