tortoise-extensions 0.0.1a1__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.
@@ -0,0 +1,13 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["master"]
6
+ pull_request:
7
+ branches: ["master"]
8
+
9
+ jobs:
10
+ quality:
11
+ uses: ./.github/workflows/quality.yaml
12
+ permissions:
13
+ contents: read
@@ -0,0 +1,35 @@
1
+ name: Quality Checks
2
+
3
+ on:
4
+ workflow_call:
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ quality:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
12
+
13
+ - name: Setup PDM
14
+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4
15
+ with:
16
+ cache: true
17
+ python-version-file: "pyproject.toml"
18
+
19
+ - name: Install dependencies
20
+ run: pdm install --frozen-lockfile -G dev -G test -G docs
21
+
22
+ - name: Format Check
23
+ run: pdm run format:check
24
+
25
+ - name: Lint Check
26
+ run: pdm run lint
27
+
28
+ - name: Type Check
29
+ run: pdm run typecheck
30
+
31
+ - name: Tests
32
+ run: pdm run tests
33
+
34
+ - name: Build docs
35
+ run: pdm run docs:build
@@ -0,0 +1,102 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*.*.*"]
6
+
7
+ jobs:
8
+ quality:
9
+ uses: ./.github/workflows/quality.yaml
10
+ permissions:
11
+ contents: read
12
+
13
+ get-version:
14
+ name: Get Version
15
+ runs-on: ubuntu-latest
16
+ outputs:
17
+ version: ${{ steps.version.outputs.version }}
18
+ steps:
19
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20
+ with:
21
+ fetch-depth: 0
22
+
23
+ - name: Setup PDM
24
+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4
25
+ with:
26
+ cache: true
27
+ python-version-file: "pyproject.toml"
28
+
29
+ - name: Install dependencies
30
+ run: pdm install --frozen-lockfile
31
+
32
+ - name: Build package
33
+ run: pdm build
34
+
35
+ - name: Get version
36
+ id: version
37
+ run: |
38
+ VERSION=$(pdm run python -c "from tortoise_extensions._version import __version__; print(__version__)")
39
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
40
+
41
+ publish:
42
+ name: Publish
43
+ runs-on: ubuntu-latest
44
+ needs: [quality, get-version]
45
+ permissions:
46
+ id-token: write
47
+ contents: read
48
+ environment:
49
+ name: pypi
50
+ url: https://pypi.org/project/tortoise-extensions/${{ needs.get-version.outputs.version }}/
51
+ steps:
52
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
53
+ with:
54
+ fetch-depth: 0
55
+
56
+ - name: Setup PDM
57
+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4
58
+ with:
59
+ cache: true
60
+ python-version-file: "pyproject.toml"
61
+
62
+ - name: Install dependencies
63
+ run: pdm install --frozen-lockfile
64
+
65
+ - name: Build and Publish
66
+ run: pdm publish
67
+
68
+ deploy-docs:
69
+ needs: [quality, publish]
70
+ name: Deploy docs
71
+ permissions:
72
+ contents: read
73
+ pages: write
74
+ id-token: write
75
+ environment:
76
+ name: github-pages
77
+ url: ${{ steps.deployment.outputs.page_url }}
78
+ runs-on: ubuntu-latest
79
+ steps:
80
+ - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6
81
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
82
+
83
+ - name: Setup PDM
84
+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4
85
+ with:
86
+ cache: true
87
+ python-version-file: "pyproject.toml"
88
+
89
+ - name: Install dependencies
90
+ run: pdm install --frozen-lockfile -G dev -G test -G docs
91
+
92
+ - name: Build docs
93
+ run: pdm run docs:build
94
+
95
+ - name: Upload docs
96
+ uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
97
+ with:
98
+ path: site
99
+
100
+ - name: Deploy docs
101
+ uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5
102
+ id: deployment
@@ -0,0 +1,69 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # Unit test / coverage reports
30
+ htmlcov/
31
+ .tox/
32
+ .nox/
33
+ .coverage
34
+ .coverage.*
35
+ .cache
36
+ nosetests.xml
37
+ coverage.xml
38
+ *.cover
39
+ *.py.cover
40
+ .hypothesis/
41
+ .pytest_cache/
42
+ cover/
43
+
44
+ # pdm
45
+ .pdm-python
46
+ .pdm-build/
47
+ src/tortoise_extensions/_version.py
48
+
49
+ # Environments
50
+ .env
51
+ .envrc
52
+ .venv
53
+ env/
54
+ venv/
55
+ ENV/
56
+ env.bak/
57
+ venv.bak/
58
+
59
+ # Ruff
60
+ .ruff_cache/
61
+
62
+ # PyPI configuration file
63
+ .pypirc
64
+
65
+ # IDE
66
+ .idea/
67
+ .vscode/
68
+
69
+ /site/
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 NiceBots.xyz
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: tortoise-extensions
3
+ Version: 0.0.1a1
4
+ Summary: Extension field types for Tortoise ORM
5
+ Project-URL: Documentation, https://docs.nicebots.xyz/tortoise-extensions/
6
+ Project-URL: Repository, https://github.com/nicebots-xyz/tortoise-extensions
7
+ Project-URL: Issues, https://github.com/nicebots-xyz/tortoise-extensions/issues
8
+ Project-URL: Source Archive, https://github.com/nicebots-xyz/tortoise-extensions/archive/4d7e03d25e382ccc043ce9231101795a8bca206b.zip
9
+ Author-email: Paillat-dev <me@paillat.dev>
10
+ License-Expression: ISC
11
+ License-File: LICENSE
12
+ Keywords: fields,orm,pydantic,tortoise,uuid6
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: ISC License (ISCL)
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: <3.15,>=3.12
22
+ Requires-Dist: tortoise-orm<1.0.0,>=0.25.4
23
+ Provides-Extra: pydantic
24
+ Requires-Dist: pydantic~=2.0; extra == 'pydantic'
25
+ Provides-Extra: uuid6
26
+ Requires-Dist: uuid6>=2024.0.0; extra == 'uuid6'
27
+ Description-Content-Type: text/markdown
28
+
29
+ <!--
30
+ SPDX-License-Identifier: ISC
31
+ Copyright: 2026 NiceBots.xyz
32
+ -->
33
+ # tortoise-extensions
34
+
35
+ Optional extension field types for [Tortoise ORM](https://tortoise.github.io/). This package targets **Tortoise ORM 0.25.4 and later, but before 1.0** — Tortoise 1.x is not supported yet.
36
+
37
+ ## Install
38
+
39
+ Base package (requires Tortoise ORM in the supported range):
40
+
41
+ ```bash
42
+ pip install tortoise-extensions
43
+ ```
44
+
45
+ Optional extras:
46
+
47
+ ```bash
48
+ pip install tortoise-extensions[pydantic]
49
+ pip install tortoise-extensions[uuid6]
50
+ pip install tortoise-extensions[pydantic,uuid6]
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ### Pydantic JSON (`pydantic` extra)
56
+
57
+ ```python
58
+ from pydantic import BaseModel
59
+ from tortoise.models import Model
60
+
61
+ from tortoise_extensions.pydantic import PydanticJSONField
62
+
63
+
64
+ class Settings(BaseModel):
65
+ theme: str = "dark"
66
+
67
+
68
+ class AppConfig(Model):
69
+ settings: PydanticJSONField[Settings] = PydanticJSONField(
70
+ Settings, default=Settings
71
+ )
72
+
73
+ class Meta:
74
+ table = "app_configs"
75
+ ```
76
+
77
+ `PydanticJSONField` round-trips through your Pydantic model: it accepts dicts from PostgreSQL JSONB, JSON strings from SQLite, and serializes models with `model_dump(mode="json")` on save.
78
+
79
+ ### UUID v6+ (`uuid6` extra)
80
+
81
+ ```python
82
+ from tortoise.models import Model
83
+
84
+ from tortoise_extensions.uuid6 import FutureUUIDField
85
+
86
+
87
+ class Item(Model):
88
+ id: FutureUUIDField = FutureUUIDField(primary_key=True)
89
+
90
+ class Meta:
91
+ table = "items"
92
+ ```
93
+
94
+ Primary keys without an explicit `default` receive a UUID7 from the [`uuid6`](https://pypi.org/project/uuid6/) package. PostgreSQL uses the native `UUID` column type; other backends store `CHAR(36)`.
95
+
96
+ ## Contributing a new extension
97
+
98
+ 1. **Open an issue first** — describe the field behavior, SQL types per backend, which Tortoise versions you need, and the proposed optional-extra name (e.g. `pip install tortoise-extensions[myextra]`).
99
+ 2. After maintainers agree on the design, open a PR that includes:
100
+ - Implementation in `src/tortoise_extensions/<module>.py`
101
+ - Tests under `tests/`
102
+ - An entry in `[project.optional-dependencies]` if the field needs third-party packages
103
+ - README and docs updates for the new field
104
+ - ISC SPDX headers on new files (`licensor-config.yaml` applies)
105
+ 3. Run `pdm run quality` locally before pushing.
106
+
107
+ ## Documentation
108
+
109
+ Published at [docs.nicebots.xyz/tortoise-extensions](https://docs.nicebots.xyz/tortoise-extensions/).
110
+
111
+ ```bash
112
+ pdm install -G docs
113
+ pdm run docs:build
114
+ pdm run docs:preview
115
+ pdm run docs:dev
116
+ ```
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ pdm install -G dev -G test -G docs
122
+ pdm run quality
123
+ ```
124
+
125
+ Public APIs use [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings); `ruff` enforces this via `convention = "google"`.
126
+
127
+ ## License
128
+
129
+ ISC.
@@ -0,0 +1,101 @@
1
+ <!--
2
+ SPDX-License-Identifier: ISC
3
+ Copyright: 2026 NiceBots.xyz
4
+ -->
5
+ # tortoise-extensions
6
+
7
+ Optional extension field types for [Tortoise ORM](https://tortoise.github.io/). This package targets **Tortoise ORM 0.25.4 and later, but before 1.0** — Tortoise 1.x is not supported yet.
8
+
9
+ ## Install
10
+
11
+ Base package (requires Tortoise ORM in the supported range):
12
+
13
+ ```bash
14
+ pip install tortoise-extensions
15
+ ```
16
+
17
+ Optional extras:
18
+
19
+ ```bash
20
+ pip install tortoise-extensions[pydantic]
21
+ pip install tortoise-extensions[uuid6]
22
+ pip install tortoise-extensions[pydantic,uuid6]
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Pydantic JSON (`pydantic` extra)
28
+
29
+ ```python
30
+ from pydantic import BaseModel
31
+ from tortoise.models import Model
32
+
33
+ from tortoise_extensions.pydantic import PydanticJSONField
34
+
35
+
36
+ class Settings(BaseModel):
37
+ theme: str = "dark"
38
+
39
+
40
+ class AppConfig(Model):
41
+ settings: PydanticJSONField[Settings] = PydanticJSONField(
42
+ Settings, default=Settings
43
+ )
44
+
45
+ class Meta:
46
+ table = "app_configs"
47
+ ```
48
+
49
+ `PydanticJSONField` round-trips through your Pydantic model: it accepts dicts from PostgreSQL JSONB, JSON strings from SQLite, and serializes models with `model_dump(mode="json")` on save.
50
+
51
+ ### UUID v6+ (`uuid6` extra)
52
+
53
+ ```python
54
+ from tortoise.models import Model
55
+
56
+ from tortoise_extensions.uuid6 import FutureUUIDField
57
+
58
+
59
+ class Item(Model):
60
+ id: FutureUUIDField = FutureUUIDField(primary_key=True)
61
+
62
+ class Meta:
63
+ table = "items"
64
+ ```
65
+
66
+ Primary keys without an explicit `default` receive a UUID7 from the [`uuid6`](https://pypi.org/project/uuid6/) package. PostgreSQL uses the native `UUID` column type; other backends store `CHAR(36)`.
67
+
68
+ ## Contributing a new extension
69
+
70
+ 1. **Open an issue first** — describe the field behavior, SQL types per backend, which Tortoise versions you need, and the proposed optional-extra name (e.g. `pip install tortoise-extensions[myextra]`).
71
+ 2. After maintainers agree on the design, open a PR that includes:
72
+ - Implementation in `src/tortoise_extensions/<module>.py`
73
+ - Tests under `tests/`
74
+ - An entry in `[project.optional-dependencies]` if the field needs third-party packages
75
+ - README and docs updates for the new field
76
+ - ISC SPDX headers on new files (`licensor-config.yaml` applies)
77
+ 3. Run `pdm run quality` locally before pushing.
78
+
79
+ ## Documentation
80
+
81
+ Published at [docs.nicebots.xyz/tortoise-extensions](https://docs.nicebots.xyz/tortoise-extensions/).
82
+
83
+ ```bash
84
+ pdm install -G docs
85
+ pdm run docs:build
86
+ pdm run docs:preview
87
+ pdm run docs:dev
88
+ ```
89
+
90
+ ## Development
91
+
92
+ ```bash
93
+ pdm install -G dev -G test -G docs
94
+ pdm run quality
95
+ ```
96
+
97
+ Public APIs use [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings); `ruff` enforces this via `convention = "google"`.
98
+
99
+ ## License
100
+
101
+ ISC.
@@ -0,0 +1,21 @@
1
+ <!--
2
+ SPDX-License-Identifier: ISC
3
+ Copyright: 2026 NiceBots.xyz
4
+ -->
5
+ # API Reference
6
+
7
+ ## Pydantic
8
+
9
+ ::: tortoise_extensions.pydantic
10
+ options:
11
+ members:
12
+ - PydanticJSONField
13
+ show_submodules: false
14
+
15
+ ## UUID6
16
+
17
+ ::: tortoise_extensions.uuid6
18
+ options:
19
+ members:
20
+ - FutureUUIDField
21
+ show_submodules: false
@@ -0,0 +1,28 @@
1
+ <!--
2
+ SPDX-License-Identifier: ISC
3
+ Copyright: 2026 NiceBots.xyz
4
+ -->
5
+ # Contributing
6
+
7
+ ## Proposing a new extension
8
+
9
+ 1. Open an issue describing the field behavior, SQL types per backend, Tortoise version requirements, and the proposed optional-extra name.
10
+ 2. Wait for maintainer feedback before starting implementation.
11
+
12
+ ## Pull requests
13
+
14
+ Include:
15
+
16
+ - Implementation in `src/tortoise_extensions/<module>.py`
17
+ - Google-style docstrings on public APIs
18
+ - Tests under `tests/`
19
+ - Optional dependency entry in `pyproject.toml` when third-party packages are required
20
+ - Updates to `docs/usage.md` and `docs/api.md` when user-facing behavior changes
21
+
22
+ Run the quality gate locally:
23
+
24
+ ```bash
25
+ pdm install -G dev -G test -G docs
26
+ pdm run quality
27
+ pdm run docs:build
28
+ ```
@@ -0,0 +1,37 @@
1
+ <!--
2
+ SPDX-License-Identifier: ISC
3
+ Copyright: 2026 NiceBots.xyz
4
+ -->
5
+ # tortoise-extensions
6
+
7
+ `tortoise-extensions` provides optional Tortoise ORM field types as install extras.
8
+
9
+ Supported Tortoise ORM versions: **0.25.4 and later, but before 1.0**. Tortoise 1.x is not supported yet.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install tortoise-extensions[pydantic,uuid6]
15
+ ```
16
+
17
+ See [Usage](usage.md) for field-specific setup.
18
+
19
+ ## Quick example
20
+
21
+ ```python
22
+ from pydantic import BaseModel
23
+ from tortoise.models import Model
24
+
25
+ from tortoise_extensions.pydantic import PydanticJSONField
26
+
27
+
28
+ class Settings(BaseModel):
29
+ theme: str = "dark"
30
+
31
+
32
+ class AppConfig(Model):
33
+ settings: PydanticJSONField[Settings] = PydanticJSONField(Settings, default=Settings)
34
+
35
+ class Meta:
36
+ table = "app_configs"
37
+ ```
@@ -0,0 +1,56 @@
1
+ <!--
2
+ SPDX-License-Identifier: ISC
3
+ Copyright: 2026 NiceBots.xyz
4
+ -->
5
+ # Usage
6
+
7
+ Install the base package plus the extras you need:
8
+
9
+ ```bash
10
+ pip install tortoise-extensions[pydantic]
11
+ pip install tortoise-extensions[uuid6]
12
+ pip install tortoise-extensions[pydantic,uuid6]
13
+ ```
14
+
15
+ ## Pydantic JSON field
16
+
17
+ Requires the `pydantic` extra.
18
+
19
+ ```python
20
+ from pydantic import BaseModel
21
+ from tortoise.models import Model
22
+
23
+ from tortoise_extensions.pydantic import PydanticJSONField
24
+
25
+
26
+ class Settings(BaseModel):
27
+ theme: str = "dark"
28
+
29
+
30
+ class AppConfig(Model):
31
+ settings: PydanticJSONField[Settings] = PydanticJSONField(Settings, default=Settings)
32
+
33
+ class Meta:
34
+ table = "app_configs"
35
+ ```
36
+
37
+ `PydanticJSONField` validates JSON using your Pydantic model. It accepts dict values from PostgreSQL JSONB and JSON strings from SQLite.
38
+
39
+ ## UUID v6+ field
40
+
41
+ Requires the `uuid6` extra.
42
+
43
+ ```python
44
+ from tortoise.models import Model
45
+
46
+ from tortoise_extensions.uuid6 import FutureUUIDField
47
+
48
+
49
+ class Item(Model):
50
+ id: FutureUUIDField = FutureUUIDField(primary_key=True)
51
+
52
+ class Meta:
53
+ table = "items"
54
+ ```
55
+
56
+ Primary keys without an explicit `default` are assigned UUID7. PostgreSQL uses the native `UUID` column type; other backends use `CHAR(36)`.
@@ -0,0 +1,5 @@
1
+ # SPDX-License-Identifier: ISC
2
+ # Copyright: 2026 NiceBots.xyz
3
+ holder: NiceBots.xyz
4
+ spdx: ISC
5
+ year: 2026