Metadata-Version: 2.4
Name: joblib-typed-cache
Version: 0.1.0
Summary: Typed version of joblib's cache to support pydantic validation and type checking
Keywords: joblib,cache,typing,pydantic
Author: Sören Zapp
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Dist: joblib>=1.0
Requires-Python: >=3.12
Project-URL: Source, https://github.com/szapp/joblib-typed-cache
Project-URL: Issues, https://github.com/szapp/joblib-typed-cache/issues
Project-URL: Funding, https://ko-fi.com/szapp
Description-Content-Type: text/markdown

# Joblib Typed Cache

[![CI](https://github.com/szapp/joblib-typed-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/szapp/joblib-typed-cache/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/joblib-typed-cache)](https://pypi.python.org/pypi/joblib-typed-cache)
[![Python Versions](https://img.shields.io/pypi/pyversions/joblib-typed-cache)](https://github.com/szapp/joblib-typed-cache)
[![Support on Ko-fi](https://img.shields.io/badge/ko--fi-support-ff586e?logo=kofi&logoColor=white)](https://ko-fi.com/szapp)

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

```shell
uv add joblib-typed-cache
```

## Usage

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

```python
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.

```python
import pydantic

get_user_validated = validate_call(get_user)
```
