-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
refine asyncio call_exception_handler context type #6981
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
Changes from all commits
73cb1fa
3ea5c10
07a8708
ef514d6
63636ec
c9ecc07
923cc2f
eba70da
6d0b0fd
9be3e73
e7daeb7
8385b71
5fe10e9
f17ee70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,10 @@ from asyncio.futures import Future | |
from asyncio.protocols import BaseProtocol | ||
from asyncio.tasks import Task | ||
from asyncio.transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport | ||
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable, Sequence | ||
from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, Iterable, Sequence | ||
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket | ||
from typing import IO, Any, TypeVar, overload | ||
from typing_extensions import Literal, TypeAlias | ||
from typing_extensions import Literal, TypeAlias, TypedDict | ||
|
||
if sys.version_info >= (3, 7): | ||
from contextvars import Context | ||
|
@@ -23,7 +23,20 @@ else: | |
|
||
_T = TypeVar("_T") | ||
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol) | ||
_Context: TypeAlias = dict[str, Any] | ||
|
||
class _BaseContext(TypedDict): | ||
message: str | ||
|
||
class _Context(_BaseContext, total=False): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking forward to PEP 655.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
exception: BaseException | ||
future: Future[Any] | ||
task: Task[Any] | ||
handle: Handle | ||
protocol: BaseProtocol | ||
transport: BaseTransport | ||
socket: socket | ||
asyncgen: AsyncGenerator[Any, Any] | ||
|
||
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], Any] | ||
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol] | ||
_SSLContext: TypeAlias = bool | None | ssl.SSLContext | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really required? At least
default_exception_handler()
uses.get()
to access it:https://github.com/python/cpython/blob/0a222db2bca63070f429c0e613707da1bdfaf0e0/Lib/asyncio/base_events.py#L1719