Mark the distributed package as typed
michal-lightly opened this issue · comments
michal-lightly commented
Thanks for a nice library!
Although the library code is typed, the types are not propagated when the package is installed:
# test.py
from diskcache import FanoutCache
cache: FanoutCache
reveal_type(cache)
❯ mypy test.py
test.py:1: error: Skipping analyzing "diskcache": module is installed, but missing library stubs or py.typed marker [import]
test.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
test.py:4: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file)
Expected would be:
❯ mypy test.py
test.py:4: note: Revealed type is "diskcache.FanoutCache"
Success: no issues found in 1 source file
How to fix this is described in PEP 561. It should be as easy as:
- Adding an empty file named
py.typed
indiskcache
subdirectory - Adding the following to
setup.py
:
setup(
...
package_data = {
'diskcache': ['py.typed'],
},
)
Grant Jenks commented
The library is not typed.