pydantic-versions 0.1.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 (40) hide show
  1. pydantic_versions-0.1.0/.github/workflows/ci.yml +128 -0
  2. pydantic_versions-0.1.0/.github/workflows/docs.yml +27 -0
  3. pydantic_versions-0.1.0/.github/workflows/release.yml +138 -0
  4. pydantic_versions-0.1.0/.gitignore +224 -0
  5. pydantic_versions-0.1.0/.python-version +1 -0
  6. pydantic_versions-0.1.0/.readthedocs.yaml +17 -0
  7. pydantic_versions-0.1.0/CONTRIBUTING.md +60 -0
  8. pydantic_versions-0.1.0/LICENSE +201 -0
  9. pydantic_versions-0.1.0/Makefile +91 -0
  10. pydantic_versions-0.1.0/PKG-INFO +124 -0
  11. pydantic_versions-0.1.0/README.md +100 -0
  12. pydantic_versions-0.1.0/docs/assets/images/pydantic-versions-hero.png +0 -0
  13. pydantic_versions-0.1.0/docs/assets/images/pydantic-versions-icon.svg +3 -0
  14. pydantic_versions-0.1.0/docs/assets/stylesheets/pydantic-versions.css +123 -0
  15. pydantic_versions-0.1.0/docs/changelog.md +12 -0
  16. pydantic_versions-0.1.0/docs/contributing.md +42 -0
  17. pydantic_versions-0.1.0/docs/guide/adoption-guidance.md +139 -0
  18. pydantic_versions-0.1.0/docs/guide/complex-config-example.md +288 -0
  19. pydantic_versions-0.1.0/docs/guide/concepts.md +81 -0
  20. pydantic_versions-0.1.0/docs/guide/django-ninja.md +155 -0
  21. pydantic_versions-0.1.0/docs/guide/getting-started.md +133 -0
  22. pydantic_versions-0.1.0/docs/guide/migrations.md +59 -0
  23. pydantic_versions-0.1.0/docs/guide/rendering.md +71 -0
  24. pydantic_versions-0.1.0/docs/guide/schema-patches.md +65 -0
  25. pydantic_versions-0.1.0/docs/guide/version-discovery.md +108 -0
  26. pydantic_versions-0.1.0/docs/index.md +49 -0
  27. pydantic_versions-0.1.0/docs/reference/api.md +79 -0
  28. pydantic_versions-0.1.0/pyproject.toml +100 -0
  29. pydantic_versions-0.1.0/src/pydantic_versions/__init__.py +54 -0
  30. pydantic_versions-0.1.0/src/pydantic_versions/core.py +501 -0
  31. pydantic_versions-0.1.0/src/pydantic_versions/exceptions.py +25 -0
  32. pydantic_versions-0.1.0/src/pydantic_versions/patches.py +58 -0
  33. pydantic_versions-0.1.0/src/pydantic_versions/py.typed +1 -0
  34. pydantic_versions-0.1.0/tests/__init__.py +1 -0
  35. pydantic_versions-0.1.0/tests/unit/__init__.py +1 -0
  36. pydantic_versions-0.1.0/tests/unit/test_django_ninja_compat.py +290 -0
  37. pydantic_versions-0.1.0/tests/unit/test_import.py +18 -0
  38. pydantic_versions-0.1.0/tests/unit/test_versioned_schema.py +473 -0
  39. pydantic_versions-0.1.0/uv.lock +656 -0
  40. pydantic_versions-0.1.0/zensical.toml +47 -0
@@ -0,0 +1,128 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ name: Lint & Format
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v4
18
+ with:
19
+ version: "latest"
20
+
21
+ - name: Set up Python
22
+ run: uv python install 3.12
23
+
24
+ - name: Install dependencies
25
+ run: uv sync --frozen
26
+
27
+ - name: Check formatting
28
+ run: uv run ruff format --check .
29
+
30
+ - name: Check linting
31
+ run: uv run ruff check .
32
+
33
+ docs:
34
+ name: Docs Build
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+
39
+ - name: Install uv
40
+ uses: astral-sh/setup-uv@v4
41
+ with:
42
+ version: "latest"
43
+
44
+ - name: Set up Python
45
+ run: uv python install 3.12
46
+
47
+ - name: Install dependencies
48
+ run: uv sync --frozen
49
+
50
+ - name: Build docs
51
+ run: make docs-build-strict
52
+
53
+ typecheck:
54
+ name: Type Check
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+
59
+ - name: Install uv
60
+ uses: astral-sh/setup-uv@v4
61
+ with:
62
+ version: "latest"
63
+
64
+ - name: Set up Python
65
+ run: uv python install 3.12
66
+
67
+ - name: Install dependencies
68
+ run: uv sync --frozen
69
+
70
+ - name: Type check
71
+ run: uv run ty check
72
+
73
+ test:
74
+ name: Test (Python ${{ matrix.python-version }})
75
+ runs-on: ubuntu-latest
76
+ strategy:
77
+ fail-fast: false
78
+ matrix:
79
+ python-version: ["3.12", "3.13"]
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+
83
+ - name: Install uv
84
+ uses: astral-sh/setup-uv@v4
85
+ with:
86
+ version: "latest"
87
+
88
+ - name: Set up Python ${{ matrix.python-version }}
89
+ run: uv python install ${{ matrix.python-version }}
90
+
91
+ - name: Install dependencies
92
+ run: uv sync --frozen
93
+
94
+ - name: Run tests
95
+ run: uv run pytest --cov=src --cov-report=xml --cov-report=term -v
96
+
97
+ - name: Upload coverage to Codecov
98
+ if: matrix.python-version == '3.12'
99
+ uses: codecov/codecov-action@v4
100
+ with:
101
+ files: ./coverage.xml
102
+ fail_ci_if_error: false
103
+ env:
104
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
105
+
106
+ build:
107
+ name: Build Package
108
+ runs-on: ubuntu-latest
109
+ needs: [lint, docs, typecheck, test]
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+
113
+ - name: Install uv
114
+ uses: astral-sh/setup-uv@v4
115
+ with:
116
+ version: "latest"
117
+
118
+ - name: Set up Python
119
+ run: uv python install 3.12
120
+
121
+ - name: Build package
122
+ run: uv build
123
+
124
+ - name: Upload dist artifacts
125
+ uses: actions/upload-artifact@v4
126
+ with:
127
+ name: dist
128
+ path: dist/
@@ -0,0 +1,27 @@
1
+ name: Docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ name: Build Docs
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v4
17
+ with:
18
+ version: "latest"
19
+
20
+ - name: Set up Python
21
+ run: uv python install 3.12
22
+
23
+ - name: Install dependencies
24
+ run: uv sync --frozen
25
+
26
+ - name: Build docs
27
+ run: make docs-build-strict
@@ -0,0 +1,138 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+ inputs:
9
+ version:
10
+ description: "Version to release (e.g., 0.1.0)"
11
+ required: true
12
+ type: string
13
+
14
+ jobs:
15
+ build:
16
+ name: Build Package
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v4
23
+ with:
24
+ version: "latest"
25
+
26
+ - name: Set up Python
27
+ run: uv python install 3.12
28
+
29
+ - name: Install dependencies
30
+ run: uv sync --frozen
31
+
32
+ - name: Build package
33
+ run: uv build
34
+
35
+ - name: Upload dist artifacts
36
+ uses: actions/upload-artifact@v4
37
+ with:
38
+ name: dist
39
+ path: dist/
40
+
41
+ test:
42
+ name: Test Built Package
43
+ runs-on: ubuntu-latest
44
+ needs: build
45
+ strategy:
46
+ matrix:
47
+ python-version: ["3.12", "3.13"]
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+
51
+ - name: Install uv
52
+ uses: astral-sh/setup-uv@v4
53
+ with:
54
+ version: "latest"
55
+
56
+ - name: Set up Python ${{ matrix.python-version }}
57
+ run: uv python install ${{ matrix.python-version }}
58
+
59
+ - name: Download dist artifacts
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ name: dist
63
+ path: dist/
64
+
65
+ - name: Create venv and install built package
66
+ run: |
67
+ uv venv --python ${{ matrix.python-version }}
68
+ uv pip install dist/*.whl
69
+
70
+ - name: Verify import
71
+ run: |
72
+ uv run python -c "import pydantic_versions; print('pydantic-versions imported successfully')"
73
+
74
+ publish-testpypi:
75
+ name: Publish to TestPyPI
76
+ runs-on: ubuntu-latest
77
+ needs: [build, test]
78
+ if: github.event_name == 'workflow_dispatch'
79
+ environment:
80
+ name: testpypi
81
+ url: https://test.pypi.org/p/pydantic-versions
82
+ permissions:
83
+ id-token: write
84
+ steps:
85
+ - name: Download dist artifacts
86
+ uses: actions/download-artifact@v4
87
+ with:
88
+ name: dist
89
+ path: dist/
90
+
91
+ - name: Publish to TestPyPI
92
+ uses: pypa/gh-action-pypi-publish@release/v1
93
+ with:
94
+ repository-url: https://test.pypi.org/legacy/
95
+
96
+ publish-pypi:
97
+ name: Publish to PyPI
98
+ runs-on: ubuntu-latest
99
+ needs: [build, test]
100
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
101
+ environment:
102
+ name: pypi
103
+ url: https://pypi.org/p/pydantic-versions
104
+ permissions:
105
+ id-token: write
106
+ steps:
107
+ - name: Download dist artifacts
108
+ uses: actions/download-artifact@v4
109
+ with:
110
+ name: dist
111
+ path: dist/
112
+
113
+ - name: Publish to PyPI
114
+ uses: pypa/gh-action-pypi-publish@release/v1
115
+
116
+ github-release:
117
+ name: Create GitHub Release
118
+ runs-on: ubuntu-latest
119
+ needs: publish-pypi
120
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
121
+ permissions:
122
+ contents: write
123
+ steps:
124
+ - uses: actions/checkout@v4
125
+
126
+ - name: Download dist artifacts
127
+ uses: actions/download-artifact@v4
128
+ with:
129
+ name: dist
130
+ path: dist/
131
+
132
+ - name: Create GitHub Release
133
+ uses: softprops/action-gh-release@v1
134
+ with:
135
+ files: dist/*
136
+ generate_release_notes: true
137
+ draft: false
138
+ prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
@@ -0,0 +1,224 @@
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
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Generated documentation site
213
+ site/
214
+
215
+ # Local scratch
216
+ tmp/
217
+
218
+ # Marimo
219
+ marimo/_static/
220
+ marimo/_lsp/
221
+ __marimo__/
222
+
223
+ # Streamlit
224
+ .streamlit/secrets.toml
@@ -0,0 +1 @@
1
+ 3.12.12
@@ -0,0 +1,17 @@
1
+ # Read the Docs configuration file.
2
+ # Zensical is not one of Read the Docs' built-in builders, so this uses the
3
+ # custom static-site flow and writes generated HTML to $READTHEDOCS_OUTPUT/html.
4
+
5
+ version: 2
6
+
7
+ build:
8
+ os: ubuntu-24.04
9
+ tools:
10
+ python: "3.12"
11
+ commands:
12
+ - python -m pip install --upgrade pip
13
+ - python -m pip install uv
14
+ - uv sync --frozen --only-dev --no-install-project
15
+ - uv run --no-sync zensical build --strict
16
+ - mkdir -p "$READTHEDOCS_OUTPUT/html"
17
+ - cp -r site/. "$READTHEDOCS_OUTPUT/html/"
@@ -0,0 +1,60 @@
1
+ # Contributing
2
+
3
+ ## Local setup
4
+
5
+ Install dependencies:
6
+
7
+ ```bash
8
+ uv sync
9
+ ```
10
+
11
+ Run checks:
12
+
13
+ ```bash
14
+ make ci
15
+ ```
16
+
17
+ ## Development commands
18
+
19
+ - `make format`: format with Ruff.
20
+ - `make lint`: lint and auto-fix with Ruff.
21
+ - `make typecheck`: run `ty`.
22
+ - `make test`: run the test suite.
23
+ - `make docs-build`: build the documentation site.
24
+
25
+ ## Commit messages
26
+
27
+ Use a concise conventional subject followed by a descriptive body when the change is more than a small mechanical edit.
28
+
29
+ The subject should:
30
+
31
+ - Use a conventional prefix such as `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `chore:`, or `release:`.
32
+ - Describe the project change directly.
33
+ - Stay short enough to scan in `git log --oneline`.
34
+
35
+ The body should:
36
+
37
+ - Explain what changed and why it changed.
38
+ - Describe user-facing, developer-facing, or maintenance impact when relevant.
39
+ - Mention important tradeoffs, compatibility notes, or follow-up constraints.
40
+ - Include a `Validation:` paragraph with the checks that were actually run.
41
+
42
+ Avoid putting transient process context in commit history. Commit messages should not mention private planning conversations, temporary scaffolding sources, other repositories used only as inspiration, or who requested the work unless that context is directly relevant to the project itself.
43
+
44
+ Example:
45
+
46
+ ```text
47
+ feat: add versioned schema API
48
+
49
+ Add the initial public API for registering versioned Pydantic schemas,
50
+ generating historical models, validating historical payloads, rendering older
51
+ schema shapes, and upgrading data to the current model through explicit
52
+ migrations.
53
+
54
+ Document the main config-versioning workflow, legacy unversioned fallback
55
+ behavior, nested version fields, Django Ninja compatibility, and release setup.
56
+ Cover the implementation with unit tests for registration, patching, migration,
57
+ dumping, nested models, and Django Ninja schemas.
58
+
59
+ Validation: make ci; uv run zensical build --strict; uv build
60
+ ```