Open KapJI opened 3 years ago
I found this is caused by this file: https://github.com/home-assistant/core/blob/dev/homeassistant/generated/zeroconf.py
If I rename it, the errors go away.
It should be imported by homeassistant.generated.zeroconf
but mypy sees it instead of actual zeroconf
which supposed to be imported.
Looks like a bug.
This issue still exists on the latest master.
❯ mypy --version
mypy 0.820+dev.bab4e22f1d0207ebc17ee3388d2434484aa998f4
It turns out homeassistant/generated/
doesn't contain __init__.py
.
Although import from homeassistant.generated import zeroconf
works in other place and mypy didn't complain that homeassistant.generated
is not a module.
I resolved this issue for my case but it still seems that something is weird with import resolution in mypy.
Bug Report
Mypy returns errors when it's used to check the whole package but doesn't return any errors when it's run on individual files.
These errors are the same as when you don't have corresponding package (
zeroconf
in this case) installed. Butzeroconf==0.29.0
is installed and it exports typing information (marked withpy.typed
).Maybe I'm doing something wrong but I don't get why mypy can't see this typing info.
This may be relevant. Sometimes I have mypy crashing with:
This is probably related to https://github.com/python/mypy/issues/7281 It disappears after removing
.mypy_cache
but may appear again after some time.To Reproduce I'm experiencing this on https://github.com/home-assistant/core/pull/48450
git clone https://github.com/home-assistant/core.git && cd core
git fetch origin pull/48450/head:zeroconf-typing
git checkout zeroconf-typing
script/setup
source venv/bin/activate
pip install xknx zeroconf
mypy homeassistant
Expected Behavior
Mypy doesn't return errors in all these cases.
Actual Behavior
Mypy returns errors when it's run for the whole package but doesn't return any errors when it's run on individual files.
Your Environment
mypy homeassistant
mypy.ini
(and other config files):setup.cfg