Skip to content

mypy error - Module 'aiohttp' has no attribute 'ClientTimeout' #3468

Closed
@thanosexcite

Description

@thanosexcite

Long story short

I have the following example Python file:

example.py

from aiohttp import ClientSession
from aiohttp import ClientTimeout

timeout = ClientTimeout()
print(timeout)

Expected behaviour

Mypy returns no errors.

Actual behaviour

Running mypy on the above example file returns the following error:

example.py:2: error: Module 'aiohttp' has no attribute 'ClientTimeout'

Steps to reproduce

$ docker run --rm -it -v `pwd`:`pwd` python:3.6.7-slim bash
root@8a1b86a205ee:/# pip install mypy aiohttp
...
Successfully installed aiohttp-3.5.1 async-timeout-3.0.1 attrs-18.2.0 chardet-3.0.4 idna-2.8 idna-ssl-1.1.0 multidict-4.5.2 mypy-0.650 mypy-extensions-0.4.1 typed-ast-1.1.1 typing-extensions-3.6.6 yarl-1.3.0
root@8a1b86a205ee:/# python /home/thanos/Dev/example/example.py 
ClientTimeout(total=None, connect=None, sock_read=None, sock_connect=None)
root@8a1b86a205ee:/# mypy /home/thanos/Dev/example/example.py 
home/thanos/Dev/example/example.py:2: error: Module 'aiohttp' has no attribute 'ClientTimeout'

Activity

added this to the 3.5 milestone on Dec 27, 2018
aio-libs-bot

aio-libs-bot commented on Dec 27, 2018

@aio-libs-bot

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #3242 (Error), #2840 (AttributeError: module 'asyncio' has no attribute 'current_task'), #843 (ImportError: No module named 'aiohttp'), #1753 (aiohttp.errors is gone), and #1059 (error install aiohttp).

asvetlov

asvetlov commented on Dec 27, 2018

@asvetlov
Member

Looks like mypy doesn't respect wildcard imports like

from .client import *  # noqa

We should get rid of wildcards everywhere.
Looks like trio did it for the same reason.

The fix should be backported to 3.5

asvetlov

asvetlov commented on Dec 27, 2018

@asvetlov
Member

@thanosexcite are you interested in making a PR with fix?

webknjaz

webknjaz commented on Dec 27, 2018

@webknjaz
Member

Other linters like pylint also fail to follow wildcard imports BTW. It's an old known issue.

thanosexcite

thanosexcite commented on Dec 27, 2018

@thanosexcite
ContributorAuthor

@asvetlov OK, I'll give it a shot. Should I make the PR to master or to the 3.5 branch?

asvetlov

asvetlov commented on Dec 27, 2018

@asvetlov
Member

PR for the master would be enough.
I'll backport it on merging.

asvetlov

asvetlov commented on Dec 28, 2018

@asvetlov
Member

Fixed by #3469

lock

lock commented on Dec 28, 2019

@lock

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

locked as resolved and limited conversation to collaborators on Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      mypy error - Module 'aiohttp' has no attribute 'ClientTimeout' · Issue #3468 · aio-libs/aiohttp