Skip to main content

Typed version of joblib's cache to support pydantic validation and type checking

Project description

Joblib Typed Cache

CI PyPI Python Versions Support on Ko-fi

Joblib's cache functionality in joblib.Memory does not preserve type annotations of the underlying function. That poses obstacles for pydantic validation and for modern type checkers and autocompletion in IDEs.

This package simply defines an incomplete adapter for the cache functionality.

Installation

uv add joblib-typed-cache

Usage

The package offers a drop-in replacement for joblib.Memory.cache.

from typed_joblib_cache import Memory

cache = Memory(location="~/.cache", verbose=0)


@cache(ignore=["db_connection"])
def get_user(user_id: str, db_connection: str) -> dict[str, str]:
    # Simulate data retrieval
    return {"user_id": user_id, "email": "john@example.com", "transaction_id": 42}

In this example, the function get_user will retain helpful tooltips in IDE and can also be used in conjunction with pydantic type validation.

import pydantic

get_user_validated = validate_call(get_user)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

joblib_typed_cache-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joblib_typed_cache-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file joblib_typed_cache-0.1.0.tar.gz.

File metadata

  • Download URL: joblib_typed_cache-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for joblib_typed_cache-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2dfb52dfa825cad25756217941f5df4d4996e34775dfa25ecb7c3c5b6234a84
MD5 ac82ee862e16beb0963a93dace82ea4c
BLAKE2b-256 ba4b0b2ce04d3bd2b412168d95d5180cf0e5c90482f18b6fbbb3c39defe6412c

See more details on using hashes here.

Provenance

The following attestation bundles were made for joblib_typed_cache-0.1.0.tar.gz:

Publisher: pypi.yml on szapp/joblib-typed-cache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file joblib_typed_cache-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for joblib_typed_cache-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d87656bc33e993e86b657346209d2296cfb83a5b12277bcb722cfb2fc2aaaafc
MD5 dd405845caa426e78af73f704e2345cc
BLAKE2b-256 0353a1944714c15bbd0edb9eb85086eab51581148d1f8521d7418c022aafb1b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for joblib_typed_cache-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on szapp/joblib-typed-cache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page