tinydantic 0.3.0__tar.gz → 0.3.1__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.
- {tinydantic-0.3.0 → tinydantic-0.3.1}/PKG-INFO +1 -1
- {tinydantic-0.3.0 → tinydantic-0.3.1}/pyproject.toml +2 -2
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/__init__.py +6 -3
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/_errors.py +2 -2
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/tinydb/storages.py +12 -7
- {tinydantic-0.3.0 → tinydantic-0.3.1}/LICENSES/Apache-2.0.txt +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/LICENSES/CC-BY-4.0.txt +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/LICENSES/MIT.txt +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/README.md +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/_config.py +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/_model.py +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/py.typed +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/tinydb/__init__.py +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/tinydb/middlewares.py +0 -0
- {tinydantic-0.3.0 → tinydantic-0.3.1}/src/tinydantic/tinydb/operations.py +0 -0
|
@@ -50,7 +50,7 @@ license-files = [
|
|
|
50
50
|
name = "tinydantic"
|
|
51
51
|
readme = "README.md"
|
|
52
52
|
requires-python = ">=3.10"
|
|
53
|
-
version = "0.3.
|
|
53
|
+
version = "0.3.1"
|
|
54
54
|
|
|
55
55
|
[project.urls]
|
|
56
56
|
Changelog = "https://github.com/tinydantic/tinydantic/blob/main/CHANGELOG.md"
|
|
@@ -219,7 +219,7 @@ verbose = 2
|
|
|
219
219
|
python_version = "3.10"
|
|
220
220
|
|
|
221
221
|
[tool.pytest.ini_options]
|
|
222
|
-
addopts = "--doctest-modules --doctest-glob '*.md'
|
|
222
|
+
addopts = "--doctest-modules --doctest-glob '*.md'"
|
|
223
223
|
doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL"
|
|
224
224
|
filterwarnings = [
|
|
225
225
|
# The queries.md "shadowing" section deliberately defines a field named
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
4
4
|
|
|
5
|
-
"""
|
|
6
|
-
|
|
5
|
+
"""A simple Python object-document mapper (ODM) for TinyDB.
|
|
6
|
+
|
|
7
|
+
`tinydantic` maps Python objects to and from documents stored in
|
|
8
|
+
the [TinyDB](https://tinydb.readthedocs.io/en/latest/) document
|
|
9
|
+
database.
|
|
7
10
|
|
|
8
11
|
Attributes:
|
|
9
12
|
__version__: The `tinydantic` package version.
|
|
10
|
-
"""
|
|
13
|
+
"""
|
|
11
14
|
|
|
12
15
|
from importlib import metadata
|
|
13
16
|
|
|
@@ -64,7 +64,7 @@ class DocumentNotFoundError(TinydanticError):
|
|
|
64
64
|
"""Requested document is not found."""
|
|
65
65
|
|
|
66
66
|
def __init__(self) -> None:
|
|
67
|
-
"""
|
|
67
|
+
"""Initialize with the "Document not found" message."""
|
|
68
68
|
super().__init__("Document not found")
|
|
69
69
|
|
|
70
70
|
|
|
@@ -72,5 +72,5 @@ class DocumentIDRequiredError(TinydanticError):
|
|
|
72
72
|
"""Required document ID is missing."""
|
|
73
73
|
|
|
74
74
|
def __init__(self) -> None:
|
|
75
|
-
"""
|
|
75
|
+
"""Initialize with the "Document ID is required" message."""
|
|
76
76
|
super().__init__("Document ID is required")
|
|
@@ -31,7 +31,7 @@ class YAMLStorage(Storage):
|
|
|
31
31
|
create_dirs: bool = False,
|
|
32
32
|
encoding: str | None = None,
|
|
33
33
|
access_mode: str = "r+",
|
|
34
|
-
**kwargs,
|
|
34
|
+
**kwargs: Any,
|
|
35
35
|
) -> None:
|
|
36
36
|
"""Create a new instance.
|
|
37
37
|
|
|
@@ -41,9 +41,14 @@ class YAMLStorage(Storage):
|
|
|
41
41
|
Note: Using an access mode other than `r` or `r+` will probably
|
|
42
42
|
lead to data loss or data corruption!
|
|
43
43
|
|
|
44
|
-
:
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
Args:
|
|
45
|
+
path: Where to store the YAML data.
|
|
46
|
+
create_dirs: Whether to create all missing parent
|
|
47
|
+
directories of the storage file.
|
|
48
|
+
encoding: The encoding used to open the storage file.
|
|
49
|
+
access_mode: Mode in which the file is opened (`r`, `r+`).
|
|
50
|
+
**kwargs: Additional keyword arguments passed to
|
|
51
|
+
`yaml.dump()` when writing data.
|
|
47
52
|
"""
|
|
48
53
|
super().__init__()
|
|
49
54
|
|
|
@@ -74,9 +79,9 @@ class YAMLStorage(Storage):
|
|
|
74
79
|
def read(self) -> dict[str, dict[str, Any]] | None:
|
|
75
80
|
"""Read data from storage.
|
|
76
81
|
|
|
77
|
-
:
|
|
78
|
-
storage
|
|
79
|
-
|
|
82
|
+
Returns:
|
|
83
|
+
A python dict containing the database data from storage,
|
|
84
|
+
or `None` if the storage file is empty.
|
|
80
85
|
"""
|
|
81
86
|
# Get the file size by moving the cursor to the file end and
|
|
82
87
|
# reading its location
|
|
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
|