apexdevkit 1.10.1__tar.gz → 1.11.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/PKG-INFO +1 -1
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/base.py +6 -3
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/in_memory.py +20 -26
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/interface.py +4 -1
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/pyproject.toml +1 -1
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/LICENSE +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/README.md +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/error.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.10.1 → apexdevkit-1.11.2}/apexdevkit/testing/rest.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import Iterator
|
|
1
|
+
from typing import Any, Generic, Iterator
|
|
2
2
|
|
|
3
|
-
from apexdevkit.repository.interface import IdT, ItemT
|
|
3
|
+
from apexdevkit.repository.interface import IdT, ItemT
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class RepositoryBase(
|
|
6
|
+
class RepositoryBase(Generic[IdT, ItemT]): # pragma: no cover
|
|
7
7
|
def create(self, item: ItemT) -> ItemT:
|
|
8
8
|
raise NotImplementedError
|
|
9
9
|
|
|
@@ -22,6 +22,9 @@ class RepositoryBase(Repository[IdT, ItemT]): # pragma: no cover
|
|
|
22
22
|
def delete(self, item_id: IdT) -> None:
|
|
23
23
|
raise NotImplementedError
|
|
24
24
|
|
|
25
|
+
def bind(self, **kwargs: Any) -> None:
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
|
|
25
28
|
def __iter__(self) -> Iterator[ItemT]:
|
|
26
29
|
raise NotImplementedError
|
|
27
30
|
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
from copy import deepcopy
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
|
-
from typing import Any, Callable,
|
|
3
|
+
from typing import Any, Callable, Iterable, Iterator, Self
|
|
4
4
|
|
|
5
5
|
from apexdevkit.error import DoesNotExistError, ExistsError
|
|
6
|
-
from apexdevkit.formatter import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class _Item(Protocol): # pragma: no cover
|
|
10
|
-
@property
|
|
11
|
-
def id(self) -> Any:
|
|
12
|
-
pass
|
|
13
|
-
|
|
6
|
+
from apexdevkit.formatter import Formatter
|
|
7
|
+
from apexdevkit.repository import RepositoryBase
|
|
8
|
+
from apexdevkit.repository.interface import IdT, ItemT
|
|
14
9
|
|
|
15
10
|
KeyFunction = Callable[[Any], str]
|
|
16
|
-
|
|
17
|
-
ItemT = TypeVar("ItemT", bound=_Item)
|
|
18
11
|
_Raw = dict[str, Any]
|
|
19
12
|
|
|
20
13
|
|
|
@@ -27,16 +20,12 @@ class AttributeKey:
|
|
|
27
20
|
|
|
28
21
|
|
|
29
22
|
@dataclass
|
|
30
|
-
class InMemoryRepository(
|
|
23
|
+
class InMemoryRepository(RepositoryBase[IdT, ItemT]):
|
|
31
24
|
formatter: Formatter[_Raw, ItemT]
|
|
32
25
|
items: dict[str, _Raw] = field(default_factory=dict)
|
|
33
26
|
|
|
34
27
|
_key_functions: list[KeyFunction] = field(init=False, default_factory=list)
|
|
35
28
|
|
|
36
|
-
@classmethod
|
|
37
|
-
def for_dataclass(cls, value: type[ItemT]) -> "InMemoryRepository[ItemT]":
|
|
38
|
-
return cls(DataclassFormatter(value))
|
|
39
|
-
|
|
40
29
|
def with_key(self, function: KeyFunction) -> Self:
|
|
41
30
|
self._key_functions.append(function)
|
|
42
31
|
|
|
@@ -55,7 +44,7 @@ class InMemoryRepository(Generic[ItemT]):
|
|
|
55
44
|
|
|
56
45
|
def create(self, item: ItemT) -> ItemT:
|
|
57
46
|
self._ensure_does_not_exist(item)
|
|
58
|
-
self.items[
|
|
47
|
+
self.items[self._key_functions[0](item)] = deepcopy(self.formatter.dump(item))
|
|
59
48
|
|
|
60
49
|
return item
|
|
61
50
|
|
|
@@ -69,27 +58,32 @@ class InMemoryRepository(Generic[ItemT]):
|
|
|
69
58
|
|
|
70
59
|
error.fire()
|
|
71
60
|
|
|
72
|
-
def read(self, item_id:
|
|
73
|
-
for
|
|
74
|
-
for
|
|
61
|
+
def read(self, item_id: IdT) -> ItemT:
|
|
62
|
+
for key in self._key_functions:
|
|
63
|
+
for item in self:
|
|
75
64
|
if key(item) == str(item_id):
|
|
76
65
|
return item
|
|
77
66
|
|
|
78
67
|
raise DoesNotExistError(item_id)
|
|
79
68
|
|
|
80
69
|
def update(self, item: ItemT) -> None:
|
|
81
|
-
|
|
70
|
+
try:
|
|
71
|
+
del self.items[self._key_functions[0](item)]
|
|
72
|
+
except KeyError:
|
|
73
|
+
raise DoesNotExistError(self._key_functions[0](item))
|
|
82
74
|
self.create(item)
|
|
83
75
|
|
|
84
76
|
def update_many(self, items: list[ItemT]) -> None:
|
|
85
77
|
for item in items:
|
|
86
78
|
self.update(item)
|
|
87
79
|
|
|
88
|
-
def delete(self, item_id:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
def delete(self, item_id: IdT) -> None:
|
|
81
|
+
for key in self._key_functions:
|
|
82
|
+
for item in self:
|
|
83
|
+
if key(item) == str(item_id):
|
|
84
|
+
del self.items[self._key_functions[0](item)]
|
|
85
|
+
return
|
|
86
|
+
raise DoesNotExistError(item_id)
|
|
93
87
|
|
|
94
88
|
def search(self, **kwargs: Any) -> Iterable[ItemT]:
|
|
95
89
|
items = []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Iterator, Protocol, TypeVar
|
|
1
|
+
from typing import Any, Iterator, Protocol, TypeVar
|
|
2
2
|
|
|
3
3
|
ItemT = TypeVar("ItemT")
|
|
4
4
|
IdT = TypeVar("IdT", contravariant=True)
|
|
@@ -23,6 +23,9 @@ class Repository(Protocol[IdT, ItemT]): # pragma: no cover
|
|
|
23
23
|
def delete(self, item_id: IdT) -> None:
|
|
24
24
|
pass
|
|
25
25
|
|
|
26
|
+
def bind(self, **kwargs: Any) -> None:
|
|
27
|
+
pass
|
|
28
|
+
|
|
26
29
|
def __iter__(self) -> Iterator[ItemT]:
|
|
27
30
|
pass
|
|
28
31
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|