Skip to content
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

Wrong type hint for tracing Signal sequence #3595

stj opened this issue Feb 6, 2019 · 4 comments

Wrong type hint for tracing Signal sequence #3595

stj opened this issue Feb 6, 2019 · 4 comments


Copy link

@stj stj commented Feb 6, 2019

Long story short

Type hints for tracing Signal contents look wrong.

Expected behaviour

mypy does not report an error when adding handlers to a signal object.

Actual behaviour

mypy reports an error of

error: List item 0 has incompatible type "Callable[[ClientSession, SimpleNamespace, TraceConnectionCreateEndParams], Coroutine[Any, Any, None]]"; expected "Callable[[TraceConfig], Awaitable[None]]"

Steps to reproduce

Run mypy over this snippet

import types

import aiohttp
import datadog

async def reuse_keepalive_connection(
    session: aiohttp.ClientSession,
    trace_config_ctx: types.SimpleNamespace,
    params: aiohttp.TraceConnectionReuseconnParams,
) -> None:
    """statsd counter; how often has a connection been reused"""

tracer = aiohttp.TraceConfig()

Your environment

aiohttp 3.5.4
python 3.7.2
mypy 0.660

Copy link

@aio-libs-bot aio-libs-bot commented Feb 6, 2019 thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #401 (Signals), #1749 (Type hinting in code), #3230 (iter_chunks type annotation wrong), #3032 (Doc: signals), and #1309 (Client Tracing).

Copy link

@asvetlov asvetlov commented May 8, 2019

Fixed by #3596

Copy link

@mvbrn mvbrn commented May 4, 2020

The similar issue still appears for me:

class RequestLogger:
    async def _on_request_start(
        session: aiohttp.ClientSession,
        context: SimpleNamespace,
        params: aiohttp.TraceRequestStartParams,
    ) -> None:

    def make_trace_config(self):
        tc = aiohttp.TraceConfig()
        return tc

results with:

 error: Argument 1 to "append" of "MutableSequence" has incompatible type "Callable[[ClientSession, SimpleNamespace, TraceRequestStartParams], Coroutine[Any, Any, None]]"; expected "Callable[[ClientSession, SimpleNamespace, <union: 15 items>], Awaitable[None]]"

Python 3.7.7
mypy 0.770

Copy link

@asvetlov asvetlov commented Oct 22, 2020

type annotation is reimplemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants