grantjenks / python-diskcache

Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.

Home Page:http://www.grantjenks.com/docs/diskcache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mark the distributed package as typed

michal-lightly opened this issue · comments

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 in diskcache subdirectory
  • Adding the following to setup.py:
setup(
    ...
    package_data = {
        'diskcache': ['py.typed'],
    },
)

The library is not typed.