Skip to content

Commit

Permalink
Fix type hint for tracing Signal sequence content
Browse files Browse the repository at this point in the history
The Signal is instantiated with a TraceConfig object but does not store
it in its mutable sequence. Fixed hinting to reflect what is expected to
be added as signal handler.
  • Loading branch information
stj authored and Stefan Tjarks committed Feb 6, 2019
1 parent 36331ce commit 1d6e774
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/xxxx.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``Signal`` type annotation changed from `Signal[Callable[['TraceConfig'], Awaitable[None]]]` to `Signal[Callable[ClientSession, SimpleNamespace, ...]`.
14 changes: 12 additions & 2 deletions aiohttp/tracing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from types import SimpleNamespace
from typing import TYPE_CHECKING, Awaitable, Callable, Type
from typing import TYPE_CHECKING, Union, Callable, Type

import attr
from multidict import CIMultiDict # noqa
Expand All @@ -11,7 +11,17 @@
if TYPE_CHECKING: # pragma: no cover
from .client import ClientSession # noqa

_Signal = Signal[Callable[['TraceConfig'], Awaitable[None]]]
params = Union[
'TraceRequestStartParams', 'TraceRequestEndParams',
'TraceRequestExceptionParams', 'TraceConnectionQueuedStartParams',
'TraceConnectionQueuedEndParams', 'TraceConnectionCreateStartParams',
'TraceConnectionCreateEndParams', 'TraceConnectionReuseconnParams',
'TraceDnsResolveHostStartParams', 'TraceDnsResolveHostEndParams',
'TraceDnsCacheHitParams', 'TraceDnsCacheMissParams',
'TraceRequestRedirectParams',
'TraceRequestChunkSentParams', 'TraceResponseChunkReceivedParams',
]
_Signal = Signal[Callable[[ClientSession, SimpleNamespace, params], None]]
else:
_Signal = Signal

Expand Down

0 comments on commit 1d6e774

Please sign in to comment.