Skip to content

Mypy and Asyncio import cannot be skipped #6383

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

Closed
Mulugruntz opened this issue Feb 13, 2019 · 3 comments
Closed

Mypy and Asyncio import cannot be skipped #6383

Mulugruntz opened this issue Feb 13, 2019 · 3 comments

Comments

@Mulugruntz
Copy link

As it seems to be an issue on mypy and on asyncio, I've reported it on both sides, even though I'm not sure exactly where the problem(s) is(are).

Some asyncio modules cannot be found with mypy. And cannot be silenced/skipped by mypy.

Have the following 3 files:

# example1.py
from asyncio import BaseEventLoop  # Module 'asyncio' has no attribute 'BaseEventLoop'
from asyncio import Semaphore  # OK
import aiostream  # gets skipped correctly
import asyncio  # OK
asyncio.windows_events.WindowsProactorEventLoopPolicy()  # Module has no attribute 'windows_events'
asyncio.WindowsProactorEventLoopPolicy()  # Module has no attribute 'WindowsProactorEventLoopPolicy'
# mypy.ini
[mypy]
python_version = 3.7

[mypy-asyncio,aiostream]
follow_imports = skip
ignore_missing_imports = True
# Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
mypy = "==0.670"
aiostream = "==0.3.1"

[requires]
python_version = "3.7"
$> pipenv install
#...
$> pipenv run python -m mypy --config-file mypy.ini example1.py
example1.py:1: error: Module 'asyncio' has no attribute 'BaseEventLoop'
example1.py:5: error: Module has no attribute "windows_events"
example1.py:6: error: Module has no attribute "WindowsProactorEventLoopPolicy"

Why Semaphore (and others) works and BaseEventLoop (among others) doesn't work... no idea.
But it completely breaks mypy that it somehow cannot be skipped nor silenced.

@tirkarthi
Copy link
Member

This is be a typeshed issue. Please see : python/typeshed#2313

@ilevkivskyi
Copy link
Member

Yes, this is a typeshed issue. Also ignore_missing_imports ignores missing modules (absent stubs), not module attributes (incomplete stubs).

But it completely breaks mypy that it somehow cannot be skipped nor silenced.

Have you heard about # type: ignore?

@Mulugruntz
Copy link
Author

@ilevkivskyi Yes, in the meantime I've used (and abused of) # type: ignore... which was what I was trying to avoid ;-)
Thanks for the info.

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

No branches or pull requests

3 participants