Skip to content

Ship type stubs and allow installing on Python 3.9 - #29

Merged
avgvi merged 3 commits into
masterfrom
feat/types-and-python-3.9
Oct 19, 2026
Merged

avgvi merged 3 commits into
masterfrom
feat/types-and-python-3.9

Conversation

@avgvi

@avgvi avgvi commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Two packaging changes that unblock libraries switching to the fork.

Type stubs. The package now ships py.typed and .pyi stubs, so mypy and pyright check code that uses diskcache_community without a separate stubs package. Libraries that type-check strictly against the diskcache-stubs package (pySigma, for example) fail with "missing library stubs or py.typed marker" on 5.8.0.

  • They cover the upstream API and the fork's additions: SafeDisk and with_types, Disk.with_options and on_error, configure, default_disk, ReadOnlyError, Cache(read_only=...) and the read_only property, store_time on get, iterkeys(tag=...), disk=None defaults, and disk on Deque, Index, FanoutCache.deque and FanoutCache.index.
  • __delitem__ and reset move from the shared protocol to Cache, and FanoutCache declares its own, matching the runtime.
  • Cache._con and Cache._sql are declared, since subclasses such as dvc-data's HashesCache run SQL through them, and Index.fromcache returns Index[Any, Any] so callers need no annotation.
  • .pylintrc skips .pyi files; blue and isort format them.

Python 3.9. requires-python is now >=3.9. The code already runs there: the full suite passes on CPython 3.9.25 (517 passed, 98.79 % coverage). Until now pip refused to install the fork on 3.9, which blocks projects that still support it, such as dvc-data.

Checked:

  • python -m mypy.stubtest diskcache_community reports no differences from the runtime, with Django installed (allowlisted: the stub-only _types module, and DjangoCache in __init__, which exists only when Django is installed).
  • pySigma's strict mypy run passes against a wheel from this branch with its imports switched to diskcache_community and diskcache-stubs removed; against 5.8.0 it fails with the missing-stubs error.
  • dvc-data's mypy run passes against a wheel from this branch once its own Cache subclass is fixed (a type[...] annotation, store_time on its get override and one type: ignore), and its 219 tests pass on Python 3.12 and 3.9.
  • The wheel contains py.typed and all seven .pyi files.
  • The full test suite passes on Python 3.12 (517 passed, 98.99 %) and 3.9; bluecheck, isortcheck, flake8, mypy, pylint (on 3.12, as in CI) and doc8 pass.

@avgvi
avgvi force-pushed the feat/types-and-python-3.9 branch from 13ec27f to b6dcafe Compare October 19, 2026 01:53
@avgvi
avgvi merged commit c4790c3 into master Oct 19, 2026
23 checks passed
@avgvi
avgvi deleted the feat/types-and-python-3.9 branch October 19, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant