apexdevkit 1.5.5__tar.gz → 1.5.6__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.5.5 → apexdevkit-1.5.6}/PKG-INFO +1 -1
- apexdevkit-1.5.6/apexdevkit/formatter.py +35 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/pyproject.toml +1 -1
- apexdevkit-1.5.5/apexdevkit/formatter.py +0 -23
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/LICENSE +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/README.md +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/error.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.5.5 → apexdevkit-1.5.6}/apexdevkit/testing/rest.py +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from dataclasses import asdict, dataclass, field
|
|
2
|
+
from typing import Any, Generic, Protocol, Self, TypeVar
|
|
3
|
+
|
|
4
|
+
ItemT = TypeVar("ItemT")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Formatter(Protocol[ItemT]): # pragma: no cover
|
|
8
|
+
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class DataclassFormatter(Generic[ItemT]):
|
|
17
|
+
resource: type[ItemT]
|
|
18
|
+
sub_formatters: dict[str, Formatter[Any]] = field(default_factory=dict)
|
|
19
|
+
|
|
20
|
+
def and_nested(self, **formatters: Formatter[Any]) -> Self:
|
|
21
|
+
return self.with_nested(**formatters)
|
|
22
|
+
|
|
23
|
+
def with_nested(self, **formatters: Formatter[Any]) -> Self:
|
|
24
|
+
self.sub_formatters.update(formatters)
|
|
25
|
+
|
|
26
|
+
return self
|
|
27
|
+
|
|
28
|
+
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
29
|
+
for key, formatter in self.sub_formatters.items():
|
|
30
|
+
raw[key] = formatter.load(raw.pop(key))
|
|
31
|
+
|
|
32
|
+
return self.resource(**raw)
|
|
33
|
+
|
|
34
|
+
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
35
|
+
return asdict(item) # type: ignore
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from dataclasses import asdict, dataclass
|
|
2
|
-
from typing import Any, Generic, Protocol, TypeVar
|
|
3
|
-
|
|
4
|
-
ItemT = TypeVar("ItemT")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Formatter(Protocol[ItemT]):
|
|
8
|
-
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
9
|
-
pass
|
|
10
|
-
|
|
11
|
-
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@dataclass
|
|
16
|
-
class DataclassFormatter(Generic[ItemT]):
|
|
17
|
-
resource: type[ItemT]
|
|
18
|
-
|
|
19
|
-
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
20
|
-
return self.resource(**raw)
|
|
21
|
-
|
|
22
|
-
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
23
|
-
return asdict(item) # type: ignore
|
|
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
|