Typing annotations are unusable for external code
jolaf opened this issue · comments
Vasily Zakharov commented
While webcolors
has typing annotations in the code (which is amazing!), unfortunately those annotation can't be used by mypy
to actually check the code against those annotations.
$ cat test.py
import webcolors
$ mypy test.py
test.py:1: error: Skipping analyzing 'webcolors': found module but no type hints or library stubs
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.812
$ python --version
Python 3.9.2
The reason for that is webcolors
get installed as site-packages/webcolors.py
, but for mypy
to be able to use the typing annotations in the code, it should be installed as site-packages/webcolors/__init__.py
, with empty site-packages/webcolors/py.typed
file present.
See https://mypy.readthedocs.io/en/stable/installed_packages.html for details.
Dominic Davis-Foster commented
I proposed the same thing last year in #10
Vasily Zakharov commented
Oops. :(