This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Mypy and Asyncio import cannot be skipped
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Samuel GIFFARD, asvetlov, gvanrossum, levkivskyi, xtreak, yselivanov
Priority: normal Keywords:

Created on 2019-02-13 13:43 by Samuel GIFFARD, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg335439 - (view) Author: Samuel GIFFARD (Samuel GIFFARD) Date: 2019-02-13 13:43
Some 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.
msg335441 - (view) Author: Samuel GIFFARD (Samuel GIFFARD) Date: 2019-02-13 14:00
I've created a similar ticket on mypy side: https://github.com/python/mypy/issues/6383 as I'm not sure where this belongs to.
msg335444 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-02-13 14:08
Thanks for the report. mypy is not part of stdlib and it seems that typeshed doesn't have BaseEventLoop defined in asyncio.__init__.pyi [0] . Adding it to the import removes the error . I guess this needs to be filed in typeshed. There is an issue open for missing asyncio top level functions at https://github.com/python/typeshed/issues/2313 . I would propose closing this as third party. I am adding mypy devs as a confirmation and to follow up the issue with typeshed for updating stub files.


[0] https://github.com/python/typeshed/blob/b3aac58db01c6bdc63452066bd9cd5f761e79044/stdlib/3/asyncio/__init__.pyi#L101
msg335445 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2019-02-13 14:26
This is not a Python issue, this should be reported on typeshed tracker (but likely a duplicate of the issue mentioned by Karthikeyan).
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80168
2019-02-13 14:26:11levkivskyisetstatus: open -> closed
resolution: third party
messages: + msg335445

stage: resolved
2019-02-13 14:08:16xtreaksetnosy: + levkivskyi, gvanrossum, xtreak
messages: + msg335444
2019-02-13 14:00:49Samuel GIFFARDsetmessages: + msg335441
2019-02-13 13:43:38Samuel GIFFARDcreate