{"id":21130,"library":"diskcache-stubs","title":"diskcache-stubs","description":"Type stubs for the diskcache library, enabling type checking and IDE autocompletion. Current version 5.6.3.6.20240818, updated infrequently to match diskcache releases.","status":"active","version":"5.6.3.6.20240818","language":"python","source_language":"en","source_url":"https://github.com/phi-friday/diskcache-stubs","tags":["type-stubs","typing","diskcache","mypy","static-analysis"],"install":[{"cmd":"pip install diskcache-stubs","lang":"bash","label":"Install"}],"dependencies":[{"reason":"Runtime dependency; stubs are useless without the actual library.","package":"diskcache","optional":false}],"imports":[{"note":"diskcache-stubs is not a runtime replacement; import from diskcache.","wrong":"from diskcache_stubs import Cache","symbol":"Cache","correct":"from diskcache import Cache"},{"note":"Stubs augment diskcache; don't import from the stubs package directly.","wrong":"from diskcache_stubs import FanoutCache","symbol":"FanoutCache","correct":"from diskcache import FanoutCache"},{"note":"The memoize decorator is in diskcache; stubs provide typing.","wrong":"from diskcache_stubs import Memoized","symbol":"Memoized","correct":"from diskcache import memoize"},{"note":"Available after installing diskcache-stubs for type hints.","wrong":"","symbol":"DjangoCache","correct":"from diskcache import DjangoCache"}],"quickstart":{"code":"from diskcache import Cache\ncache = Cache('/tmp/my_cache')\ncache.set('key', 'value')\nprint(cache.get('key'))","lang":"python","description":"Create a disk cache, set and get a value. Type hints will be available after installing diskcache-stubs."},"warnings":[{"fix":"pip install diskcache diskcache-stubs","message":"Installing diskcache-stubs does not install diskcache. You must install diskcache separately.","severity":"gotcha","affected_versions":"all"},{"fix":"from diskcache import Cache","message":"Do not import directly from diskcache_stubs. Import from the diskcache package.","severity":"gotcha","affected_versions":"all"},{"fix":"Check diskcache version: pip show diskcache; then install matching stubs: pip install diskcache-stubs==5.6.3.x","message":"The stubs version includes the diskcache version (e.g., 5.6.3) and a stub patch number. Ensure compatibility by matching the diskcache major.minor.patch.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to latest: pip install --upgrade diskcache-stubs","message":"Old versions of diskcache-stubs (<5.6.3) may have incomplete type annotations for newer diskcache features.","severity":"deprecated","affected_versions":"<5.6.3"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install diskcache","cause":"diskcache not installed; only stubs are installed.","error":"ImportError: cannot import name 'Cache' from 'diskcache'"},{"fix":"Import from diskcache; ensure diskcache-stubs is installed for type hints.","cause":"Attempting to import from diskcache_stubs directly or missing installation.","error":"ModuleNotFoundError: No module named 'diskcache_stubs'"},{"fix":"Use: from diskcache import Cache; cache = Cache('/tmp')","cause":"Trying to use diskcache as a class instead of importing subclasses.","error":"TypeError: 'module' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}