Skip to content

Commit 22281c9

Browse files
committed
fix(core): improve argument types of Cache
1 parent 3a0b499 commit 22281c9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.github/workflows/test_and_version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
python-version: ["3.10", "3.11", "3.12"]
35+
python-version: ['3.10', '3.11', '3.12']
3636
steps:
3737
- uses: actions/checkout@v3
3838
- name: Set up Python ${{ matrix.python-version }}

class_cache/core.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
from abc import abstractmethod
2-
from typing import Any, ClassVar, Iterable
2+
from typing import Any, Callable, ClassVar, Iterable
33

44
from replete.consistent_hash import consistent_hash
55

6-
from class_cache.backends import PickleBackend
7-
from class_cache.types import CacheInterface, KeyType, ValueType
6+
from class_cache.backends import SQLiteBackend
7+
from class_cache.types import CacheInterface, IdType, KeyType, ValueType
88

9-
DEFAULT_BACKEND_TYPE = PickleBackend
9+
DEFAULT_BACKEND_TYPE = SQLiteBackend
1010

1111

1212
class Cache(CacheInterface[KeyType, ValueType]):
13-
def __init__(self, id_: str | int | None = None, backend_type: type[CacheInterface] = DEFAULT_BACKEND_TYPE) -> None:
13+
def __init__(
14+
self,
15+
id_: IdType = None,
16+
backend_type: type[CacheInterface] | Callable[[IdType], CacheInterface] = DEFAULT_BACKEND_TYPE,
17+
) -> None:
1418
super().__init__(id_)
1519
self._backend = backend_type(id_)
1620
# TODO: Implement max_size logic

0 commit comments

Comments
 (0)