tinydantic 0.1.18__tar.gz → 0.2.0__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.
Files changed (43) hide show
  1. tinydantic-0.2.0/PKG-INFO +190 -0
  2. tinydantic-0.2.0/README.md +155 -0
  3. tinydantic-0.2.0/pyproject.toml +230 -0
  4. tinydantic-0.2.0/src/tinydantic/__init__.py +38 -0
  5. tinydantic-0.2.0/src/tinydantic/_config.py +137 -0
  6. tinydantic-0.2.0/src/tinydantic/_errors.py +76 -0
  7. tinydantic-0.2.0/src/tinydantic/_model.py +650 -0
  8. {tinydantic-0.1.18/tests → tinydantic-0.2.0/src/tinydantic/tinydb}/__init__.py +1 -1
  9. tinydantic-0.2.0/src/tinydantic/tinydb/middlewares.py +89 -0
  10. tinydantic-0.2.0/src/tinydantic/tinydb/operations.py +31 -0
  11. tinydantic-0.2.0/src/tinydantic/tinydb/storages.py +120 -0
  12. tinydantic-0.1.18/.editorconfig +0 -31
  13. tinydantic-0.1.18/.github/workflows/ci.yaml +0 -80
  14. tinydantic-0.1.18/.github/workflows/docs-dev.yaml +0 -60
  15. tinydantic-0.1.18/.github/workflows/docs-release.yaml +0 -63
  16. tinydantic-0.1.18/.github/workflows/publish-python-package.yaml +0 -120
  17. tinydantic-0.1.18/.gitignore +0 -171
  18. tinydantic-0.1.18/.linkcheckerrc +0 -8
  19. tinydantic-0.1.18/.markdownlint.yaml +0 -13
  20. tinydantic-0.1.18/.pre-commit-config.yaml +0 -84
  21. tinydantic-0.1.18/.prettierrc.yaml +0 -22
  22. tinydantic-0.1.18/.vscode/extensions.json +0 -18
  23. tinydantic-0.1.18/.yamllint.yaml +0 -33
  24. tinydantic-0.1.18/LICENSE.md +0 -25
  25. tinydantic-0.1.18/PKG-INFO +0 -82
  26. tinydantic-0.1.18/README.md +0 -23
  27. tinydantic-0.1.18/REUSE.toml +0 -25
  28. tinydantic-0.1.18/docs/.pages +0 -9
  29. tinydantic-0.1.18/docs/css/code_select.css +0 -10
  30. tinydantic-0.1.18/docs/index.md +0 -9
  31. tinydantic-0.1.18/docs/installation.md +0 -7
  32. tinydantic-0.1.18/docs/reference/.pages +0 -52
  33. tinydantic-0.1.18/docs/reference/index.md +0 -5
  34. tinydantic-0.1.18/mkdocs.yaml +0 -126
  35. tinydantic-0.1.18/pyproject.toml +0 -290
  36. tinydantic-0.1.18/scripts/gen_api_docs.py +0 -161
  37. tinydantic-0.1.18/src/tinydantic/__init__.py +0 -17
  38. tinydantic-0.1.18/taplo.toml +0 -38
  39. tinydantic-0.1.18/tests/test_version.py +0 -30
  40. {tinydantic-0.1.18 → tinydantic-0.2.0}/LICENSES/Apache-2.0.txt +0 -0
  41. {tinydantic-0.1.18 → tinydantic-0.2.0}/LICENSES/CC-BY-4.0.txt +0 -0
  42. {tinydantic-0.1.18 → tinydantic-0.2.0}/LICENSES/MIT.txt +0 -0
  43. {tinydantic-0.1.18 → tinydantic-0.2.0}/src/tinydantic/py.typed +0 -0
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: tinydantic
3
+ Version: 0.2.0
4
+ Summary: A Pydantic-powered ODM (object-document mapper) for TinyDB
5
+ Keywords: odm,pydantic,tinydb
6
+ Author: Chris Wilson
7
+ Author-email: Chris Wilson <christopher.david.wilson@gmail.com>
8
+ License-Expression: Apache-2.0 OR MIT
9
+ License-File: LICENSES/Apache-2.0.txt
10
+ License-File: LICENSES/CC-BY-4.0.txt
11
+ License-File: LICENSES/MIT.txt
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Framework :: Pydantic :: 2
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python
23
+ Classifier: Topic :: Database
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Typing :: Typed
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: pydantic[email]>=2.11
28
+ Requires-Dist: tinydb>=4.8
29
+ Requires-Python: >=3.11
30
+ Project-URL: Changelog, https://github.com/tinydantic/tinydantic/blob/main/CHANGELOG.md
31
+ Project-URL: Documentation, https://tinydantic.dev
32
+ Project-URL: Issues, https://github.com/tinydantic/tinydantic/issues
33
+ Project-URL: Source, https://github.com/tinydantic/tinydantic
34
+ Description-Content-Type: text/markdown
35
+
36
+ # tinydantic
37
+
38
+ <!-- overview-start -->
39
+
40
+ [![PyPI - Version](https://img.shields.io/pypi/v/tinydantic.svg)](https://pypi.org/project/tinydantic) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinydantic.svg)](https://pypi.org/project/tinydantic) [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
41
+
42
+ `tinydantic` is a simple Python object-document mapper (ODM) for the [TinyDB](https://tinydb.readthedocs.io/en/latest/) document database. It uses [Pydantic](https://docs.pydantic.dev/latest/)—the most widely used data validation library—for document model definition and validation.
43
+
44
+ <!-- prettier-ignore-start -->
45
+
46
+ > [!NOTE]
47
+ > `tinydantic` is under active development. Releases follow the [SemVer versioning spec](https://semver.org):
48
+ >
49
+ > > Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
50
+ >
51
+ > Minor releases may include breaking changes until v1.0 — check the [changelog](https://github.com/tinydantic/tinydantic/blob/main/CHANGELOG.md) when upgrading. Feedback is welcome!
52
+
53
+ <!-- prettier-ignore-end -->
54
+
55
+ <!-- overview-end -->
56
+
57
+ Full documentation is available at [tinydantic.dev](https://tinydantic.dev).
58
+
59
+ ## Table of Contents
60
+
61
+ - [Installation](#installation)
62
+ - [Introduction](#introduction)
63
+ - [Basic Example](#basic-example)
64
+ - [License](#license)
65
+
66
+ ## Introduction
67
+
68
+ <!-- introduction-start -->
69
+
70
+ `tinydantic` is a wrapper library around [TinyDB](https://tinydb.readthedocs.io/en/latest/) that enables using [Pydantic](https://docs.pydantic.dev/) models to manage documents stored in a TinyDB database. By specifying Python type annotations for each field in a document model, data validation is handled automatically by Pydantic when instantiating a model from the database.
71
+
72
+ <!-- introduction-end -->
73
+
74
+ ## Installation
75
+
76
+ <!-- installation-start -->
77
+
78
+ `tinydantic` is [available on PyPI](https://pypi.org/project/tinydantic/) and can be installed with [pip](https://github.com/pypa/pip). Easy peasy lemon squeezy 🍋
79
+
80
+ ```sh
81
+ pip install tinydantic
82
+ ```
83
+
84
+ <!-- installation-end -->
85
+
86
+ ## Basic Example
87
+
88
+ <!-- basic-example-start -->
89
+
90
+ Here's a basic example showing how to create, insert, and query for a document using `tinydantic`.
91
+
92
+ ### Using `tinydantic` models
93
+
94
+ First, create a TinyDB database where the documents will be stored. In this example, we're using an in-memory database, but TinyDB supports other [storage types](https://tinydb.readthedocs.io/en/latest/usage.html#storage-types) which can store the database persistently as JSON, YAML, etc.
95
+
96
+ ```pycon
97
+ >>> from tinydb import TinyDB
98
+ >>> from tinydb.storages import MemoryStorage
99
+ >>> db = TinyDB(storage=MemoryStorage)
100
+
101
+ ```
102
+
103
+ Create a `User` document model, configuring it to store documents in the `users` table of the `db` database.
104
+
105
+ > [!TIP]
106
+ >
107
+ > Since `User` is a subclass of [TinydanticModel][tinydantic.TinydanticModel] (which itself is a subclass of [pydantic.BaseModel][]), `User` is also a Pydantic model! You have all the power of Pydantic models when creating a `tinydantic` document model.
108
+
109
+ ```pycon
110
+ >>> from pydantic import EmailStr
111
+ >>> from tinydantic import TinydanticModel
112
+ >>> class User(TinydanticModel, database=db, table_name='users'):
113
+ ... name: str
114
+ ... email: EmailStr
115
+
116
+ ```
117
+
118
+ Create a new `User` instance for a user named "Alice".
119
+
120
+ ```pycon
121
+ >>> alice = User(name='Alice', email='alice@example.com')
122
+
123
+ ```
124
+
125
+ Insert `alice` into the database.
126
+
127
+ ```pycon
128
+ >>> alice.insert()
129
+ User(id=1, name='Alice', email='alice@example.com')
130
+
131
+ ```
132
+
133
+ Query the database for users with the name "Alice". Notice that this returns a `User` instance that was automatically validated by Pydantic!
134
+
135
+ ```pycon
136
+ >>> User.get(User.name == 'Alice')
137
+ User(id=1, name='Alice', email='alice@example.com')
138
+
139
+ ```
140
+
141
+ ### Comparison to TinyDB
142
+
143
+ Since `tinydantic` is built on top of TinyDB, you can still use `tinydb` to interact with the database directly if needed.
144
+
145
+ For comparison, let's try to accomplish the same task as shown above using only TinyDB _without_ `tinydantic`. For this example, we'll continue using the same database (`db`) we created earlier.
146
+
147
+ ```pycon
148
+ >>> users_table = db.table('users')
149
+ >>> users_table.insert({'name': 'Bob', 'email': 'bob@example.com'})
150
+ 2
151
+ >>> from tinydb import where
152
+ >>> users_table.get(where('name') == 'Bob')
153
+ {'name': 'Bob', 'email': 'bob@example.com'}
154
+
155
+ ```
156
+
157
+ Notice, that TinyDB does not impose any restrictions on the document we insert _into_ the database table. Additionally, there is no automatic parsing or validation of the data _returned_ from the database.
158
+
159
+ ### Pydantic validation in action
160
+
161
+ _What happens if an invalid document is somehow returned from the database?_
162
+
163
+ Let's set up a contrived example to test the automatic Pydantic validation.
164
+
165
+ First, we'll manually insert a document that is missing the `email` field from the `User` model we created earlier.
166
+
167
+ ```pycon
168
+ >>> users_table.insert({'name': 'Carol'})
169
+ 3
170
+
171
+ ```
172
+
173
+ Next, we'll query for users named "Bob" using the tinydantic model we created earlier.
174
+
175
+ ```pycon
176
+ >>> User.get(User.name == 'Carol')
177
+ Traceback (most recent call last):
178
+ ...
179
+ pydantic_core._pydantic_core.ValidationError: 1 validation error for User
180
+ email
181
+ Field required [type=missing, input_value={'name': 'Carol'}, input_type=Document]
182
+ ```
183
+
184
+ As you can see, Pydantic produced a `ValidationError` because the document returned from the database is missing the `email` field required by the `User` model.
185
+
186
+ <!-- basic-example-end -->
187
+
188
+ ## License
189
+
190
+ See the [LICENSE](https://github.com/tinydantic/tinydantic/blob/main/LICENSE.md) file for copyright & license information.
@@ -0,0 +1,155 @@
1
+ # tinydantic
2
+
3
+ <!-- overview-start -->
4
+
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/tinydantic.svg)](https://pypi.org/project/tinydantic) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinydantic.svg)](https://pypi.org/project/tinydantic) [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
6
+
7
+ `tinydantic` is a simple Python object-document mapper (ODM) for the [TinyDB](https://tinydb.readthedocs.io/en/latest/) document database. It uses [Pydantic](https://docs.pydantic.dev/latest/)—the most widely used data validation library—for document model definition and validation.
8
+
9
+ <!-- prettier-ignore-start -->
10
+
11
+ > [!NOTE]
12
+ > `tinydantic` is under active development. Releases follow the [SemVer versioning spec](https://semver.org):
13
+ >
14
+ > > Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
15
+ >
16
+ > Minor releases may include breaking changes until v1.0 — check the [changelog](https://github.com/tinydantic/tinydantic/blob/main/CHANGELOG.md) when upgrading. Feedback is welcome!
17
+
18
+ <!-- prettier-ignore-end -->
19
+
20
+ <!-- overview-end -->
21
+
22
+ Full documentation is available at [tinydantic.dev](https://tinydantic.dev).
23
+
24
+ ## Table of Contents
25
+
26
+ - [Installation](#installation)
27
+ - [Introduction](#introduction)
28
+ - [Basic Example](#basic-example)
29
+ - [License](#license)
30
+
31
+ ## Introduction
32
+
33
+ <!-- introduction-start -->
34
+
35
+ `tinydantic` is a wrapper library around [TinyDB](https://tinydb.readthedocs.io/en/latest/) that enables using [Pydantic](https://docs.pydantic.dev/) models to manage documents stored in a TinyDB database. By specifying Python type annotations for each field in a document model, data validation is handled automatically by Pydantic when instantiating a model from the database.
36
+
37
+ <!-- introduction-end -->
38
+
39
+ ## Installation
40
+
41
+ <!-- installation-start -->
42
+
43
+ `tinydantic` is [available on PyPI](https://pypi.org/project/tinydantic/) and can be installed with [pip](https://github.com/pypa/pip). Easy peasy lemon squeezy 🍋
44
+
45
+ ```sh
46
+ pip install tinydantic
47
+ ```
48
+
49
+ <!-- installation-end -->
50
+
51
+ ## Basic Example
52
+
53
+ <!-- basic-example-start -->
54
+
55
+ Here's a basic example showing how to create, insert, and query for a document using `tinydantic`.
56
+
57
+ ### Using `tinydantic` models
58
+
59
+ First, create a TinyDB database where the documents will be stored. In this example, we're using an in-memory database, but TinyDB supports other [storage types](https://tinydb.readthedocs.io/en/latest/usage.html#storage-types) which can store the database persistently as JSON, YAML, etc.
60
+
61
+ ```pycon
62
+ >>> from tinydb import TinyDB
63
+ >>> from tinydb.storages import MemoryStorage
64
+ >>> db = TinyDB(storage=MemoryStorage)
65
+
66
+ ```
67
+
68
+ Create a `User` document model, configuring it to store documents in the `users` table of the `db` database.
69
+
70
+ > [!TIP]
71
+ >
72
+ > Since `User` is a subclass of [TinydanticModel][tinydantic.TinydanticModel] (which itself is a subclass of [pydantic.BaseModel][]), `User` is also a Pydantic model! You have all the power of Pydantic models when creating a `tinydantic` document model.
73
+
74
+ ```pycon
75
+ >>> from pydantic import EmailStr
76
+ >>> from tinydantic import TinydanticModel
77
+ >>> class User(TinydanticModel, database=db, table_name='users'):
78
+ ... name: str
79
+ ... email: EmailStr
80
+
81
+ ```
82
+
83
+ Create a new `User` instance for a user named "Alice".
84
+
85
+ ```pycon
86
+ >>> alice = User(name='Alice', email='alice@example.com')
87
+
88
+ ```
89
+
90
+ Insert `alice` into the database.
91
+
92
+ ```pycon
93
+ >>> alice.insert()
94
+ User(id=1, name='Alice', email='alice@example.com')
95
+
96
+ ```
97
+
98
+ Query the database for users with the name "Alice". Notice that this returns a `User` instance that was automatically validated by Pydantic!
99
+
100
+ ```pycon
101
+ >>> User.get(User.name == 'Alice')
102
+ User(id=1, name='Alice', email='alice@example.com')
103
+
104
+ ```
105
+
106
+ ### Comparison to TinyDB
107
+
108
+ Since `tinydantic` is built on top of TinyDB, you can still use `tinydb` to interact with the database directly if needed.
109
+
110
+ For comparison, let's try to accomplish the same task as shown above using only TinyDB _without_ `tinydantic`. For this example, we'll continue using the same database (`db`) we created earlier.
111
+
112
+ ```pycon
113
+ >>> users_table = db.table('users')
114
+ >>> users_table.insert({'name': 'Bob', 'email': 'bob@example.com'})
115
+ 2
116
+ >>> from tinydb import where
117
+ >>> users_table.get(where('name') == 'Bob')
118
+ {'name': 'Bob', 'email': 'bob@example.com'}
119
+
120
+ ```
121
+
122
+ Notice, that TinyDB does not impose any restrictions on the document we insert _into_ the database table. Additionally, there is no automatic parsing or validation of the data _returned_ from the database.
123
+
124
+ ### Pydantic validation in action
125
+
126
+ _What happens if an invalid document is somehow returned from the database?_
127
+
128
+ Let's set up a contrived example to test the automatic Pydantic validation.
129
+
130
+ First, we'll manually insert a document that is missing the `email` field from the `User` model we created earlier.
131
+
132
+ ```pycon
133
+ >>> users_table.insert({'name': 'Carol'})
134
+ 3
135
+
136
+ ```
137
+
138
+ Next, we'll query for users named "Bob" using the tinydantic model we created earlier.
139
+
140
+ ```pycon
141
+ >>> User.get(User.name == 'Carol')
142
+ Traceback (most recent call last):
143
+ ...
144
+ pydantic_core._pydantic_core.ValidationError: 1 validation error for User
145
+ email
146
+ Field required [type=missing, input_value={'name': 'Carol'}, input_type=Document]
147
+ ```
148
+
149
+ As you can see, Pydantic produced a `ValidationError` because the document returned from the database is missing the `email` field required by the `User` model.
150
+
151
+ <!-- basic-example-end -->
152
+
153
+ ## License
154
+
155
+ See the [LICENSE](https://github.com/tinydantic/tinydantic/blob/main/LICENSE.md) file for copyright & license information.
@@ -0,0 +1,230 @@
1
+ # SPDX-FileCopyrightText: Chris Wilson <christopher.david.wilson@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
4
+
5
+ #:schema https://json.schemastore.org/pyproject.json
6
+
7
+ [build-system]
8
+ build-backend = "uv_build"
9
+ requires = [
10
+ "uv_build>=0.11,<0.12",
11
+ ]
12
+
13
+ [project]
14
+ authors = [
15
+ { name = "Chris Wilson", email = "christopher.david.wilson@gmail.com" },
16
+ ]
17
+ # https://pypi.org/classifiers/
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Framework :: Pydantic :: 2",
21
+ "Intended Audience :: Developers",
22
+ "Operating System :: OS Independent",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Programming Language :: Python :: Implementation :: CPython",
29
+ "Programming Language :: Python",
30
+ "Topic :: Database",
31
+ "Topic :: Software Development :: Libraries",
32
+ "Typing :: Typed",
33
+ ]
34
+ dependencies = [
35
+ "PyYAML>=6.0",
36
+ "pydantic[email]>=2.11",
37
+ "tinydb>=4.8",
38
+ ]
39
+ description = "A Pydantic-powered ODM (object-document mapper) for TinyDB"
40
+ keywords = [
41
+ "odm",
42
+ "pydantic",
43
+ "tinydb",
44
+ ]
45
+ license = "Apache-2.0 OR MIT"
46
+ license-files = [
47
+ "LICENSES/*",
48
+ ]
49
+ name = "tinydantic"
50
+ readme = "README.md"
51
+ requires-python = ">=3.11"
52
+ version = "0.2.0"
53
+
54
+ [project.urls]
55
+ Changelog = "https://github.com/tinydantic/tinydantic/blob/main/CHANGELOG.md"
56
+ Documentation = "https://tinydantic.dev"
57
+ Issues = "https://github.com/tinydantic/tinydantic/issues"
58
+ Source = "https://github.com/tinydantic/tinydantic"
59
+
60
+ [dependency-groups]
61
+ dev = [
62
+ "check-jsonschema",
63
+ "commitizen",
64
+ "editorconfig-checker",
65
+ "interrogate",
66
+ "jsonschema[format]",
67
+ "poethepoet",
68
+ "pre-commit",
69
+ "pre-commit-ci-config",
70
+ "pyclean",
71
+ "reuse>=5.0.0",
72
+ { include-group = "docs" },
73
+ { include-group = "lint" },
74
+ { include-group = "test" },
75
+ { include-group = "types" },
76
+ ]
77
+ docs = [
78
+ # black is used by separate_signature option in mkdocstrings-python
79
+ "black",
80
+ "fastapi",
81
+ "griffe",
82
+ "httpx",
83
+ "linkchecker",
84
+ "markdown-callouts",
85
+ "markdown-gfm-admonition",
86
+ "mdx_truly_sane_lists",
87
+ "mike",
88
+ "mkdocs-awesome-pages-plugin",
89
+ "mkdocs-gen-files",
90
+ "mkdocs-github-admonitions-plugin",
91
+ "mkdocs-include-markdown-plugin",
92
+ "mkdocs-materialx",
93
+ "mkdocstrings",
94
+ "mkdocstrings-python",
95
+ "poethepoet",
96
+ # properdocs is the docs build engine. mike >=2.2.0 auto-detects it and
97
+ # runs properdocs for versioned deploys too. The mkdocs package remains
98
+ # installed only as a transitive dependency (mkdocs-materialx pins it for
99
+ # import compatibility).
100
+ "properdocs",
101
+ ]
102
+ lint = [
103
+ "poethepoet",
104
+ "ruff>=0.14",
105
+ ]
106
+ test = [
107
+ "fastapi",
108
+ "httpx",
109
+ "packaging",
110
+ "poethepoet",
111
+ "pytest-cov",
112
+ "pytest-randomly",
113
+ "pytest-rerunfailures",
114
+ "pytest-xdist",
115
+ "pytest>=8",
116
+ ]
117
+ types = [
118
+ "mypy>=1.14",
119
+ "packaging",
120
+ "types-PyYAML",
121
+ ]
122
+
123
+ [tool.coverage.run]
124
+ branch = true
125
+ parallel = true
126
+ source_pkgs = [
127
+ "tests",
128
+ "tinydantic",
129
+ ]
130
+
131
+ [tool.coverage.paths]
132
+ tests = [
133
+ "*/tinydantic/tests",
134
+ "tests",
135
+ ]
136
+ tinydantic = [
137
+ "*/tinydantic/src/tinydantic",
138
+ "src/tinydantic",
139
+ ]
140
+
141
+ [tool.coverage.report]
142
+ exclude_lines = [
143
+ "if TYPE_CHECKING:",
144
+ "if __name__ == .__main__.:",
145
+ "no cov",
146
+ ]
147
+
148
+ [tool.commitizen]
149
+ annotated_tag = true
150
+ major_version_zero = true
151
+ name = "cz_conventional_commits"
152
+ tag_format = "v$version"
153
+ version_provider = "pep621"
154
+ version_scheme = "semver2"
155
+
156
+ [tool.poe.tasks]
157
+ clean = "pyclean . --debris --verbose"
158
+ fmt = [
159
+ "_ruff-fix",
160
+ "_ruff-format",
161
+ ]
162
+ lint = [
163
+ "_ruff-check",
164
+ "_ruff-format-check",
165
+ ]
166
+ pre-commit = "pre-commit run --all-files --verbose"
167
+ sbom = "reuse spdx -o reuse.spdx"
168
+ sbom-check = "reuse lint"
169
+ spell-check = "npx cspell --gitignore --dot ."
170
+ test = "pytest"
171
+ test-cov = "pytest --cov --cov-branch"
172
+ types = "mypy --install-types --non-interactive src/tinydantic tests"
173
+ update-project-words = { shell = "npx cspell --gitignore --dot --words-only --unique . | sort --ignore-case >> project-words.txt" }
174
+
175
+ _ruff-check = "ruff check ."
176
+ _ruff-fix = "ruff check --fix ."
177
+ _ruff-format = "ruff format ."
178
+ _ruff-format-check = "ruff format --check ."
179
+
180
+ check = [
181
+ "lint",
182
+ "sbom-check",
183
+ "spell-check",
184
+ "types",
185
+ ]
186
+
187
+ [tool.poe.tasks.docs-build]
188
+ cmd = "properdocs build --config-file mkdocs.yaml --clean --strict"
189
+ env = { PYTHONUNBUFFERED = "1", SOURCE_DATE_EPOCH = "1580601600" }
190
+
191
+ [tool.poe.tasks.docs-build-check]
192
+ sequence = [
193
+ { ref = "docs-build --no-directory-urls" },
194
+ { ref = "docs-check" },
195
+ ]
196
+
197
+ [tool.poe.tasks.docs-check]
198
+ cmd = "linkchecker --config .linkcheckerrc site"
199
+
200
+ [tool.poe.tasks.docs-ci-publish]
201
+ cmd = "mike deploy --config-file mkdocs.yaml --update-aliases --push"
202
+ env = { PYTHONUNBUFFERED = "1", SOURCE_DATE_EPOCH = "1580601600" }
203
+
204
+ [tool.poe.tasks.docs-serve]
205
+ cmd = "properdocs serve --config-file mkdocs.yaml --dev-addr localhost:8000"
206
+ env = { PYTHONUNBUFFERED = "1" }
207
+
208
+ [tool.interrogate]
209
+ fail-under = 100
210
+ ignore-overloaded-functions = true
211
+ ignore-private = true
212
+ ignore-semiprivate = true
213
+ omit-covered-files = true
214
+ style = "google"
215
+ verbose = 2
216
+
217
+ [tool.mypy]
218
+ python_version = "3.11"
219
+
220
+ [tool.pytest.ini_options]
221
+ addopts = "--doctest-modules --doctest-glob '*.md' --ignore=docs/superpowers"
222
+ doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL"
223
+ minversion = "6.0"
224
+ testpaths = [
225
+ "CONTRIBUTING.md",
226
+ "README.md",
227
+ "docs",
228
+ "src",
229
+ "tests",
230
+ ]
@@ -0,0 +1,38 @@
1
+ # SPDX-FileCopyrightText: Chris Wilson <christopher.david.wilson@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
4
+
5
+ """`tinydantic` is a simple Python object-document mapper (ODM) for the
6
+ [TinyDB](https://tinydb.readthedocs.io/en/latest/) document database.
7
+
8
+ Attributes:
9
+ __version__: The `tinydantic` package version.
10
+ """ # noqa: D205
11
+
12
+ from importlib import metadata
13
+
14
+ from tinydantic._config import TinydanticConfig
15
+ from tinydantic._errors import (
16
+ AmbiguousConfigError,
17
+ DatabaseNotBoundError,
18
+ DocumentIDRequiredError,
19
+ DocumentNotFoundError,
20
+ TinydanticError,
21
+ TinydanticUserError,
22
+ )
23
+ from tinydantic._model import TinydanticModel, q
24
+
25
+ __version__: str = metadata.version("tinydantic")
26
+
27
+ __all__ = [
28
+ "AmbiguousConfigError",
29
+ "DatabaseNotBoundError",
30
+ "DocumentIDRequiredError",
31
+ "DocumentNotFoundError",
32
+ "TinydanticConfig",
33
+ "TinydanticError",
34
+ "TinydanticModel",
35
+ "TinydanticUserError",
36
+ "__version__",
37
+ "q",
38
+ ]