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.0.1.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.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: joblib_typed_cache-0.0.1.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.0.1.tar.gz
Algorithm Hash digest
SHA256 ce523f161182d2cc222aa13312fa84aaffe086fa3c8401eceb300c6b401ece1e
MD5 19e716dd6ef85138965c84d8c5aa5a76
BLAKE2b-256 90013ae6c49d587711ffb77b75d5cd62cc3fcd852e8f2181207edf8478c61523

See more details on using hashes here.

Provenance

The following attestation bundles were made for joblib_typed_cache-0.0.1.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.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for joblib_typed_cache-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ce75fc0f5591806f8c8d94e48e1af1c1370d5fa2a4a847bd93b0884e893a8c9
MD5 c7bb97692c0e87c2c68d4145e0d1ca8d
BLAKE2b-256 29dea38bb7d2daf70711801ad9313c04a9dddeecfcb78a0ed8caa58661d28d5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for joblib_typed_cache-0.0.1-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