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

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

Closed
thanosexcite opened this issue Dec 27, 2018 · 8 comments
Closed

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

thanosexcite opened this issue Dec 27, 2018 · 8 comments
Milestone

Comments

@thanosexcite
Copy link
Contributor

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'

@asvetlov asvetlov added this to the 3.5 milestone Dec 27, 2018
@aio-libs-bot
Copy link

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
Copy link
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
Copy link
Member

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

@webknjaz
Copy link
Member

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

@thanosexcite
Copy link
Contributor Author

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

@asvetlov
Copy link
Member

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

@asvetlov
Copy link
Member

asvetlov commented Dec 28, 2018

Fixed by #3469

@lock
Copy link

lock bot commented Dec 28, 2019

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.

@lock lock bot added the outdated label Dec 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants