Closed
Description
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
aio-libs-bot commentedon Dec 27, 2018
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 commentedon Dec 27, 2018
Looks like
mypy
doesn't respect wildcard imports likeWe should get rid of wildcards everywhere.
Looks like trio did it for the same reason.
The fix should be backported to 3.5
asvetlov commentedon Dec 27, 2018
@thanosexcite are you interested in making a PR with fix?
webknjaz commentedon Dec 27, 2018
Other linters like pylint also fail to follow wildcard imports BTW. It's an old known issue.
thanosexcite commentedon Dec 27, 2018
@asvetlov OK, I'll give it a shot. Should I make the PR to master or to the 3.5 branch?
asvetlov commentedon Dec 27, 2018
PR for the master would be enough.
I'll backport it on merging.
asvetlov commentedon Dec 28, 2018
Fixed by #3469
lock commentedon 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.