cadwyn 4.4.3__tar.gz → 4.5.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.
Potentially problematic release.
This version of cadwyn might be problematic. Click here for more details.
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/actions/setup-python-uv/action.yaml +3 -3
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/workflows/ci.yaml +39 -26
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/workflows/daily_tests.yaml +2 -4
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/workflows/publish_docs.yaml +2 -2
- cadwyn-4.5.0/.github/workflows/validate_links.yaml +25 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.pre-commit-config.yaml +4 -4
- {cadwyn-4.4.3 → cadwyn-4.5.0}/CHANGELOG.md +19 -1
- cadwyn-4.5.0/Makefile +11 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/PKG-INFO +2 -2
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/_asts.py +10 -8
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/_importer.py +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/_utils.py +15 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/changelogs.py +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/route_generation.py +14 -7
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/routing.py +5 -10
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/schema_generation.py +29 -23
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/data.py +25 -13
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/endpoints.py +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/schemas.py +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/versions.py +2 -14
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/index.md +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/main_app.md +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/methodology.md +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/version_changes.md +11 -8
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_openapi_schemas/add_field.md +1 -1
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_openapi_schemas/change_field_type.md +0 -1
- cadwyn-4.5.0/docs/how_to/change_openapi_schemas/change_schema_without_endpoint.md +17 -0
- cadwyn-4.5.0/docs/img/sponsor_logos/monite.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/plugin.py +1 -3
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/theory/how_we_got_here.md +2 -2
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/theory/literature.md +1 -0
- cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint/block001.py +22 -0
- cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint/block002.py +22 -0
- cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint/tests/test_block001.py +15 -0
- cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint/tests/test_block002.py +14 -0
- cadwyn-4.5.0/docs_src/quickstart/tutorial/tests/test_block003.py +36 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/mkdocs.yml +1 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/pyproject.toml +24 -2
- {cadwyn-4.4.3 → cadwyn-4.5.0}/ruff.toml +53 -18
- {cadwyn-4.4.3/tests/_resources/versioned_app → cadwyn-4.5.0/tests/_data}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/app_for_testing_routing.py +5 -5
- cadwyn-4.5.0/tests/_resources/render/complex/__init__.py +0 -0
- cadwyn-4.5.0/tests/_resources/versioned_app/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/versioned_app/app.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/versioned_app/v2022_01_02.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/versioned_app/webhooks.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/conftest.py +0 -2
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_applications.py +2 -5
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_cli.py +2 -10
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_data_migrations.py +4 -6
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_router_generation.py +4 -6
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_routing.py +2 -2
- cadwyn-4.5.0/tests/test_schema_generation/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_schema_generation/test_schema_field.py +3 -4
- cadwyn-4.5.0/tests/tutorial/__init__.py +0 -0
- cadwyn-4.5.0/tox.ini +61 -0
- cadwyn-4.5.0/uv.lock +1631 -0
- cadwyn-4.4.3/.github/workflows/validate_links.yaml +0 -41
- cadwyn-4.4.3/Makefile +0 -14
- cadwyn-4.4.3/docs/img/sponsor_logos/monite.png +0 -0
- cadwyn-4.4.3/docs_src/quickstart/tutorial/tests/test_block003.py +0 -21
- cadwyn-4.4.3/uv.lock +0 -1567
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/CODE_OF_CONDUCT.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.github/workflows/release.yaml +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/.gitignore +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/LICENSE +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/README.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/__init__.py +9 -9
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/__main__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/_render.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/applications.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/exceptions.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/middleware.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/py.typed +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/static/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/static/docs.html +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/__init__.py +7 -7
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/common.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/cadwyn/structure/enums.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/CNAME +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/api_version_header_and_context_variables.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/beware_of_data_versioning.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/changelogs.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/cli.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/endpoint_migrations.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/enum_migrations.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/schema_generation.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/schema_migrations.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/concepts/testing.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/home/CONTRIBUTING.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_business_logic/index.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_endpoints/index.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_openapi_schemas/changing_constraints.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_openapi_schemas/remove_field.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/change_openapi_schemas/rename_a_field_in_schema.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/how_to/index.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/img/dashboard_with_one_version.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/img/dashboard_with_two_versions.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/img/get_users_endpoint_from_prior_version.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/img/simplified_migration_model.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/img/unversioned_dashboard.png +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/index.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/quickstart/setup.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/quickstart/tutorial.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs/theory/how_to_build_versioning_framework.md +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/__init__.py +0 -0
- {cadwyn-4.4.3/docs_src/quickstart → cadwyn-4.5.0/docs_src/how_to}/__init__.py +0 -0
- {cadwyn-4.4.3/docs_src/quickstart/setup → cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas}/__init__.py +0 -0
- {cadwyn-4.4.3/docs_src/quickstart/setup/tests → cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint}/__init__.py +0 -0
- {cadwyn-4.4.3/docs_src/quickstart/tutorial → cadwyn-4.5.0/docs_src/how_to/change_openapi_schemas/change_schema_without_endpoint/tests}/__init__.py +0 -0
- {cadwyn-4.4.3/docs_src/quickstart/tutorial/tests → cadwyn-4.5.0/docs_src/quickstart}/__init__.py +0 -0
- {cadwyn-4.4.3/tests/_data → cadwyn-4.5.0/docs_src/quickstart/setup}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/setup/block001.sh +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/setup/block002.py +0 -0
- {cadwyn-4.4.3/tests/_resources → cadwyn-4.5.0/docs_src/quickstart/setup/tests}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/setup/tests/test_block002.py +0 -0
- {cadwyn-4.4.3/tests/_resources/render → cadwyn-4.5.0/docs_src/quickstart/tutorial}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/tutorial/block001.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/tutorial/block002.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/tutorial/block003.py +0 -0
- {cadwyn-4.4.3/tests/_resources/render/complex → cadwyn-4.5.0/docs_src/quickstart/tutorial/tests}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/tutorial/tests/test_block001.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/docs_src/quickstart/tutorial/tests/test_block002.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/scripts/fix_links.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/scripts/split_md.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_data/unversioned_schema_dir/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_data/unversioned_schema_dir/unversioned_schemas.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_data/unversioned_schemas.py +0 -0
- {cadwyn-4.4.3/tests/test_schema_generation → cadwyn-4.5.0/tests/_resources}/__init__.py +0 -0
- {cadwyn-4.4.3/tests/tutorial → cadwyn-4.5.0/tests/_resources/render}/__init__.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/render/classes.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/render/complex/classes.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/render/complex/versions.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/render/versions.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/utils.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/_resources/versioned_app/v2021_01_01.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_auth_dependencies.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_changelog.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_render.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_schema_generation/test_enum.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_schema_generation/test_schema.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_schema_generation/test_schema_validator.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/test_structure.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/tutorial/main.py +0 -0
- {cadwyn-4.4.3 → cadwyn-4.5.0}/tests/tutorial/test_example.py +0 -0
|
@@ -8,7 +8,7 @@ inputs:
|
|
|
8
8
|
uv-version:
|
|
9
9
|
description: "The uv version to set up"
|
|
10
10
|
required: true
|
|
11
|
-
default: "0.
|
|
11
|
+
default: "0.5.8"
|
|
12
12
|
|
|
13
13
|
runs:
|
|
14
14
|
using: "composite"
|
|
@@ -16,12 +16,12 @@ runs:
|
|
|
16
16
|
- uses: actions/setup-python@v5
|
|
17
17
|
with:
|
|
18
18
|
python-version: ${{ inputs.python-version }}
|
|
19
|
-
- uses: astral-sh/setup-uv@
|
|
19
|
+
- uses: astral-sh/setup-uv@v5
|
|
20
20
|
with:
|
|
21
21
|
version: ${{ inputs.uv-version }}
|
|
22
22
|
enable-cache: true
|
|
23
23
|
cache-dependency-glob: "uv.lock"
|
|
24
24
|
- run: |
|
|
25
25
|
uv sync --frozen --all-extras --dev
|
|
26
|
-
|
|
26
|
+
uv pip install --system tox tox-uv
|
|
27
27
|
shell: bash
|
|
@@ -10,6 +10,7 @@ on:
|
|
|
10
10
|
branches: [main, 3.x.x]
|
|
11
11
|
types: [opened, synchronize]
|
|
12
12
|
paths:
|
|
13
|
+
- ".github/workflows/ci.yaml" # self
|
|
13
14
|
- "**.py"
|
|
14
15
|
- "**.toml"
|
|
15
16
|
- "**.lock"
|
|
@@ -40,13 +41,13 @@ jobs:
|
|
|
40
41
|
- uses: ./.github/actions/setup-python-uv
|
|
41
42
|
with:
|
|
42
43
|
python-version: ${{ matrix.python-version }}
|
|
43
|
-
- run:
|
|
44
|
+
- run: tox run -e py
|
|
44
45
|
- name: Upload coverage results
|
|
45
|
-
uses: actions/upload-artifact@
|
|
46
|
+
uses: actions/upload-artifact@v4
|
|
46
47
|
if: matrix.os == 'ubuntu-latest' # Cross-platform coverage combination doesn't work
|
|
47
48
|
with:
|
|
48
|
-
name:
|
|
49
|
-
path: coverage
|
|
49
|
+
name: coverage-results-${{ matrix.python-version }}
|
|
50
|
+
path: .coverage*
|
|
50
51
|
Tutorial-tests:
|
|
51
52
|
runs-on: ubuntu-latest
|
|
52
53
|
name: Tutorial tests
|
|
@@ -57,53 +58,65 @@ jobs:
|
|
|
57
58
|
python-version: "3.10"
|
|
58
59
|
- name: Install cadwyn with instructions from docs
|
|
59
60
|
run: sh docs_src/quickstart/setup/block001.sh
|
|
60
|
-
- run:
|
|
61
|
-
|
|
61
|
+
- run: |
|
|
62
|
+
pip install uv
|
|
63
|
+
uv pip install --system pytest coverage dirty-equals
|
|
64
|
+
coverage run -m pytest docs_src
|
|
62
65
|
- name: Upload coverage results
|
|
63
|
-
uses: actions/upload-artifact@
|
|
66
|
+
uses: actions/upload-artifact@v4
|
|
64
67
|
with:
|
|
65
|
-
name:
|
|
66
|
-
path: coverage
|
|
68
|
+
name: coverage-results-docs
|
|
69
|
+
path: .coverage*
|
|
67
70
|
Coverage:
|
|
68
71
|
needs: [Tests, Tutorial-tests]
|
|
69
72
|
runs-on: ubuntu-latest
|
|
70
73
|
steps:
|
|
71
74
|
- uses: actions/checkout@v4
|
|
72
|
-
- name: Download
|
|
73
|
-
uses: actions/download-artifact@
|
|
75
|
+
- name: Download coverage info
|
|
76
|
+
uses: actions/download-artifact@v4
|
|
74
77
|
with:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
uses: actions/download-artifact@v3
|
|
79
|
-
with:
|
|
80
|
-
name: docs-tests-coverage-results
|
|
81
|
-
path: coverage/
|
|
78
|
+
pattern: coverage-results-*
|
|
79
|
+
merge-multiple: true
|
|
80
|
+
path: .
|
|
82
81
|
- uses: actions/setup-python@v5
|
|
83
82
|
with:
|
|
84
83
|
python-version: "3.10"
|
|
85
|
-
- run:
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
- run: |
|
|
85
|
+
pip install uv
|
|
86
|
+
uv pip install --system tox tox-uv
|
|
87
|
+
tox run -e coverage_report-ci
|
|
88
88
|
- name: Upload to Codecov
|
|
89
89
|
uses: codecov/codecov-action@v4
|
|
90
90
|
env:
|
|
91
91
|
fail_ci_if_error: true
|
|
92
92
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
93
|
-
- run: coverage report --fail-under=100
|
|
94
93
|
|
|
95
94
|
Lint:
|
|
96
95
|
runs-on: ubuntu-latest
|
|
97
96
|
steps:
|
|
98
97
|
- uses: actions/checkout@v4
|
|
99
|
-
- uses:
|
|
98
|
+
- uses: actions/setup-python@v5
|
|
99
|
+
with:
|
|
100
|
+
python-version: "3.10"
|
|
101
|
+
- run: |
|
|
102
|
+
python -m pip install uv
|
|
103
|
+
uv pip install --system pre-commit pre-commit-uv
|
|
104
|
+
pre-commit run --all-files
|
|
105
|
+
- run: tox run -e docs
|
|
106
|
+
- name: Validate links
|
|
107
|
+
uses: umbrelladocs/action-linkspector@v1
|
|
108
|
+
with:
|
|
109
|
+
reporter: github-pr-review
|
|
110
|
+
filter_mode: diff_context
|
|
111
|
+
fail_level: any
|
|
100
112
|
|
|
101
113
|
Typecheck:
|
|
102
114
|
runs-on: ubuntu-latest
|
|
103
115
|
steps:
|
|
104
116
|
- uses: actions/checkout@v4
|
|
105
117
|
- uses: ./.github/actions/setup-python-uv
|
|
106
|
-
|
|
107
|
-
- uses: jakebailey/pyright-action@v1
|
|
108
118
|
with:
|
|
109
|
-
|
|
119
|
+
# When this version is updated,
|
|
120
|
+
# update the pyright `base_python` version in `tox.ini`, too.
|
|
121
|
+
python-version: "3.10"
|
|
122
|
+
- run: tox run -e pyright
|
|
@@ -21,10 +21,8 @@ jobs:
|
|
|
21
21
|
with:
|
|
22
22
|
python-version: ${{ matrix.python-version }}
|
|
23
23
|
- run: uv sync --refresh --all-extras --dev --upgrade
|
|
24
|
-
- run: pytest .
|
|
25
|
-
-
|
|
26
|
-
with:
|
|
27
|
-
pylance-version: latest-release
|
|
24
|
+
- run: uv run pytest . # We intentionally don't use tox here to run tests "as is"
|
|
25
|
+
- run: uv run pyright --version && uv run pyright .
|
|
28
26
|
|
|
29
27
|
notify-on-failure:
|
|
30
28
|
name: Notify on failure
|
|
@@ -14,11 +14,11 @@ jobs:
|
|
|
14
14
|
run: |
|
|
15
15
|
git config user.name github-actions[bot]
|
|
16
16
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
17
|
-
- uses: actions/setup-python@
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
18
|
with:
|
|
19
19
|
python-version: 3.x
|
|
20
20
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
|
21
|
-
- uses: actions/cache@
|
|
21
|
+
- uses: actions/cache@v4
|
|
22
22
|
with:
|
|
23
23
|
key: mkdocs-material-${{ env.cache_id }}
|
|
24
24
|
path: .cache
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Check Markdown links
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
# Run everyday at 9:00 AM
|
|
6
|
+
- cron: "0 9 * * *"
|
|
7
|
+
workflow_dispatch: # Allows manual triggering of the workflow
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-docs-to-validate-links:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: ./.github/actions/setup-python-uv
|
|
15
|
+
- run: tox run -e docs
|
|
16
|
+
|
|
17
|
+
markdown-link-check:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: umbrelladocs/action-linkspector@v1
|
|
22
|
+
with:
|
|
23
|
+
reporter: github-check
|
|
24
|
+
filter_mode: nofilter
|
|
25
|
+
fail_level: any
|
|
@@ -2,7 +2,7 @@ default_language_version:
|
|
|
2
2
|
python: python3.10
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
5
|
+
rev: v5.0.0
|
|
6
6
|
hooks:
|
|
7
7
|
- id: check-added-large-files
|
|
8
8
|
- id: check-yaml
|
|
@@ -18,14 +18,14 @@ repos:
|
|
|
18
18
|
- id: python-check-blanket-noqa
|
|
19
19
|
|
|
20
20
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
21
|
-
rev: v0.
|
|
21
|
+
rev: v0.8.1
|
|
22
22
|
hooks:
|
|
23
23
|
- id: ruff
|
|
24
24
|
args: [--fix, --exit-non-zero-on-fix]
|
|
25
25
|
- id: ruff-format
|
|
26
26
|
|
|
27
27
|
- repo: https://github.com/adamchainz/blacken-docs
|
|
28
|
-
rev: "1.
|
|
28
|
+
rev: "1.19.1" # replace with latest tag on GitHub
|
|
29
29
|
hooks:
|
|
30
30
|
- id: blacken-docs
|
|
31
31
|
additional_dependencies:
|
|
@@ -33,7 +33,7 @@ repos:
|
|
|
33
33
|
args: ["--line-length=80", "--target-version=py310", "--skip-errors"]
|
|
34
34
|
|
|
35
35
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
36
|
-
rev: v0.
|
|
36
|
+
rev: v0.43.0
|
|
37
37
|
hooks:
|
|
38
38
|
- id: markdownlint
|
|
39
39
|
args: ["--disable", "MD013"]
|
|
@@ -5,6 +5,24 @@ Please follow [the Keep a Changelog standard](https://keepachangelog.com/en/1.0.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.5.0]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
* `check_usage` argument to request/response by schema converters. Cadwyn always checks whether a schema mentioned in a converter applies to one or more endpoints to guarantee that the converter will apply to at least one endpoint. Sometimes, however, you do not need this validation. For example, when you use these converters for converting webhook bodies. Setting `check_usage=False` makes it possible to skip the validation
|
|
13
|
+
|
|
14
|
+
## [4.4.5]
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
* Fix invalid migration of pydantic v1 style root validators when pydantic erases information about their "skip_on_failure" attribute
|
|
19
|
+
|
|
20
|
+
## [4.4.4]
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
* Type hints for newest pydantic versions
|
|
25
|
+
|
|
8
26
|
## [4.4.3]
|
|
9
27
|
|
|
10
28
|
### Changed
|
|
@@ -299,7 +317,7 @@ Versions 3.x.x are still supported in terms of bug and security fixes but all th
|
|
|
299
317
|
|
|
300
318
|
### Fixed
|
|
301
319
|
|
|
302
|
-
* When a class-based dependency from **fastapi** was used (anything security related), FastAPI had hardcoded `isinstance` checks for it which it used to enrich swagger with functionality. But when the dependencies were wrapped into our function wrappers, these checks stopped passing, thus breaking this functionality in swagger. Now we ignore all dependencies that FastAPI creates. This also introduces a hard-to-solve bug: if fastapi's class-based security dependency was subclassed and then `__call__` was
|
|
320
|
+
* When a class-based dependency from **fastapi** was used (anything security related), FastAPI had hardcoded `isinstance` checks for it which it used to enrich swagger with functionality. But when the dependencies were wrapped into our function wrappers, these checks stopped passing, thus breaking this functionality in swagger. Now we ignore all dependencies that FastAPI creates. This also introduces a hard-to-solve bug: if fastapi's class-based security dependency was subclassed and then `__call__` was overridden with new dependencies that are versioned -- we will not migrate them from version to version. I hope this is an extremely rare use case though. In fact, such use case breaks Liskov Substitution Principle and doesn't make much sense because security classes already include `request` parameter which means that no extra dependencies or parameters are necessary.
|
|
303
321
|
|
|
304
322
|
## [3.6.5]
|
|
305
323
|
|
cadwyn-4.5.0/Makefile
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cadwyn
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.5.0
|
|
4
4
|
Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
|
|
5
5
|
Project-URL: Source code, https://github.com/zmievsa/cadwyn
|
|
6
6
|
Project-URL: Documentation, https://docs.cadwyn.dev
|
|
@@ -56,12 +56,13 @@ def get_fancy_repr(value: Any) -> Any:
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
def transform_grouped_metadata(value: "annotated_types.GroupedMetadata"):
|
|
59
|
-
modified_fields = []
|
|
60
59
|
empty_obj = type(value)
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
modified_fields = [
|
|
62
|
+
(key, getattr(value, key))
|
|
63
|
+
for key in value.__dataclass_fields__ # pyright: ignore[reportAttributeAccessIssue]
|
|
64
|
+
if getattr(value, key) != getattr(empty_obj, key)
|
|
65
|
+
]
|
|
65
66
|
|
|
66
67
|
return PlainRepr(
|
|
67
68
|
value.__class__.__name__
|
|
@@ -120,11 +121,12 @@ def transform_other(value: Any) -> Any:
|
|
|
120
121
|
|
|
121
122
|
|
|
122
123
|
def _get_lambda_source_from_default_factory(source: str) -> str:
|
|
123
|
-
found_lambdas: list[ast.Lambda] = [
|
|
124
|
+
found_lambdas: list[ast.Lambda] = [
|
|
125
|
+
node.value
|
|
126
|
+
for node in ast.walk(ast.parse(source))
|
|
127
|
+
if isinstance(node, ast.keyword) and node.arg == "default_factory" and isinstance(node.value, ast.Lambda)
|
|
128
|
+
]
|
|
124
129
|
|
|
125
|
-
for node in ast.walk(ast.parse(source)):
|
|
126
|
-
if isinstance(node, ast.keyword) and node.arg == "default_factory" and isinstance(node.value, ast.Lambda):
|
|
127
|
-
found_lambdas.append(node.value)
|
|
128
130
|
if len(found_lambdas) == 1:
|
|
129
131
|
return ast.unparse(found_lambdas[0])
|
|
130
132
|
# These two errors are really hard to cover. Not sure if even possible, honestly :)
|
|
@@ -7,7 +7,7 @@ from cadwyn.exceptions import ImportFromStringError
|
|
|
7
7
|
def import_attribute_from_string(import_str: str) -> Any:
|
|
8
8
|
module_str, _, attrs_str = import_str.partition(":")
|
|
9
9
|
if not module_str or not attrs_str:
|
|
10
|
-
message = 'Import string "{import_str}" must be in format "<module>:<attribute>".'
|
|
10
|
+
message = f'Import string "{import_str}" must be in format "<module>:<attribute>".'
|
|
11
11
|
raise ImportFromStringError(message.format(import_str=import_str))
|
|
12
12
|
|
|
13
13
|
module = import_module_from_string(module_str)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from collections.abc import Callable
|
|
2
|
-
from typing import Any, Generic, TypeVar, Union
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union
|
|
3
3
|
|
|
4
4
|
from pydantic._internal._decorators import unwrap_wrapped_function
|
|
5
5
|
|
|
@@ -40,3 +40,17 @@ def fully_unwrap_decorator(func: Callable, is_pydantic_v1_style_validator: Any):
|
|
|
40
40
|
if is_pydantic_v1_style_validator and func.__closure__:
|
|
41
41
|
func = func.__closure__[0].cell_contents
|
|
42
42
|
return unwrap_wrapped_function(func)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
T = TypeVar("T", bound=type[object])
|
|
46
|
+
|
|
47
|
+
if TYPE_CHECKING:
|
|
48
|
+
lenient_issubclass = issubclass
|
|
49
|
+
|
|
50
|
+
else:
|
|
51
|
+
|
|
52
|
+
def lenient_issubclass(cls: type, other: T | tuple[T, ...]) -> bool:
|
|
53
|
+
try:
|
|
54
|
+
return issubclass(cls, other)
|
|
55
|
+
except TypeError: # pragma: no cover
|
|
56
|
+
return False
|
|
@@ -160,7 +160,7 @@ def _get_openapi_representation_of_a_field(model: type[BaseModel], field_name: s
|
|
|
160
160
|
|
|
161
161
|
model_name_map = get_compat_model_name_map([CadwynDummyModelForRepresentation.model_fields["my_field"]])
|
|
162
162
|
schema_generator = GenerateJsonSchema(ref_template=REF_TEMPLATE)
|
|
163
|
-
|
|
163
|
+
_, definitions = get_definitions(
|
|
164
164
|
fields=[ModelField(CadwynDummyModelForRepresentation.model_fields["my_field"], "my_field")],
|
|
165
165
|
schema_generator=schema_generator,
|
|
166
166
|
model_name_map=model_name_map,
|
|
@@ -179,13 +179,13 @@ class _EndpointTransformer(Generic[_R, _WR]):
|
|
|
179
179
|
copy_of_dependant,
|
|
180
180
|
self.versions,
|
|
181
181
|
)
|
|
182
|
-
for
|
|
182
|
+
for router in routers.values():
|
|
183
183
|
router.routes = [
|
|
184
184
|
route
|
|
185
185
|
for route in router.routes
|
|
186
186
|
if not (isinstance(route, fastapi.routing.APIRoute) and _DELETED_ROUTE_TAG in route.tags)
|
|
187
187
|
]
|
|
188
|
-
for
|
|
188
|
+
for webhook_router in webhook_routers.values():
|
|
189
189
|
webhook_router.routes = [
|
|
190
190
|
route
|
|
191
191
|
for route in webhook_router.routes
|
|
@@ -221,6 +221,8 @@ class _EndpointTransformer(Generic[_R, _WR]):
|
|
|
221
221
|
|
|
222
222
|
for by_schema_converters in version_change.alter_request_by_schema_instructions.values():
|
|
223
223
|
for by_schema_converter in by_schema_converters:
|
|
224
|
+
if not by_schema_converter.check_usage: # pragma: no cover
|
|
225
|
+
continue
|
|
224
226
|
missing_models = set(by_schema_converter.schemas) - head_request_bodies
|
|
225
227
|
if missing_models:
|
|
226
228
|
raise RouteRequestBySchemaConverterDoesNotApplyToAnythingError(
|
|
@@ -232,6 +234,8 @@ class _EndpointTransformer(Generic[_R, _WR]):
|
|
|
232
234
|
)
|
|
233
235
|
for by_schema_converters in version_change.alter_response_by_schema_instructions.values():
|
|
234
236
|
for by_schema_converter in by_schema_converters:
|
|
237
|
+
if not by_schema_converter.check_usage: # pragma: no cover
|
|
238
|
+
continue
|
|
235
239
|
missing_models = set(by_schema_converter.schemas) - head_response_models
|
|
236
240
|
if missing_models:
|
|
237
241
|
raise RouteResponseBySchemaConverterDoesNotApplyToAnythingError(
|
|
@@ -240,6 +244,9 @@ class _EndpointTransformer(Generic[_R, _WR]):
|
|
|
240
244
|
f"failed to find routes with the following response models: "
|
|
241
245
|
f"{[m.__name__ for m in missing_models]}. "
|
|
242
246
|
f"This means that you are trying to apply this converter to non-existing endpoint(s). "
|
|
247
|
+
"If this is intentional and this converter really does not apply to any endpoints, then "
|
|
248
|
+
"pass check_usage=False argument to "
|
|
249
|
+
f"{version_change.__name__}.{by_schema_converter.transformer.__name__}"
|
|
243
250
|
)
|
|
244
251
|
|
|
245
252
|
def _extract_all_routes_identifiers(
|
|
@@ -466,18 +473,18 @@ def _get_routes(
|
|
|
466
473
|
*,
|
|
467
474
|
is_deleted: bool = False,
|
|
468
475
|
) -> list[fastapi.routing.APIRoute]:
|
|
469
|
-
found_routes = []
|
|
470
476
|
endpoint_path = endpoint_path.rstrip("/")
|
|
471
|
-
|
|
477
|
+
return [
|
|
478
|
+
route
|
|
479
|
+
for route in routes
|
|
472
480
|
if (
|
|
473
481
|
isinstance(route, fastapi.routing.APIRoute)
|
|
474
482
|
and route.path.rstrip("/") == endpoint_path
|
|
475
483
|
and set(route.methods).issubset(endpoint_methods)
|
|
476
484
|
and (endpoint_func_name is None or route.endpoint.__name__ == endpoint_func_name)
|
|
477
485
|
and (_DELETED_ROUTE_TAG in route.tags) == is_deleted
|
|
478
|
-
)
|
|
479
|
-
|
|
480
|
-
return found_routes
|
|
486
|
+
)
|
|
487
|
+
]
|
|
481
488
|
|
|
482
489
|
|
|
483
490
|
def _get_route_from_func(
|
|
@@ -23,9 +23,9 @@ _logger = getLogger(__name__)
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class _RootHeaderAPIRouter(APIRouter):
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
"""Root router of the FastAPI app when using header based versioning.
|
|
27
|
+
|
|
28
|
+
It will be used to route the requests to the correct versioned route
|
|
29
29
|
based on the headers. It also supports waterflowing the requests to the latest
|
|
30
30
|
version of the API if the request header doesn't match any of the versions.
|
|
31
31
|
|
|
@@ -88,9 +88,6 @@ class _RootHeaderAPIRouter(APIRouter):
|
|
|
88
88
|
return self.versioned_routers[version_chosen].routes
|
|
89
89
|
|
|
90
90
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
91
|
-
"""
|
|
92
|
-
The main entry point to the Router class.
|
|
93
|
-
"""
|
|
94
91
|
if "router" not in scope: # pragma: no cover
|
|
95
92
|
scope["router"] = self
|
|
96
93
|
|
|
@@ -131,10 +128,8 @@ class _RootHeaderAPIRouter(APIRouter):
|
|
|
131
128
|
self.unversioned_routes.append(self.routes[-1])
|
|
132
129
|
|
|
133
130
|
async def process_request(self, scope: Scope, receive: Receive, send: Send, routes: Sequence[BaseRoute]) -> None:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
but in this version self.routes were replaced with routes from the function arguments
|
|
137
|
-
"""
|
|
131
|
+
# It's a copy-paste from starlette.routing.Router
|
|
132
|
+
# but in this version self.routes were replaced with routes from the function arguments
|
|
138
133
|
|
|
139
134
|
partial = None
|
|
140
135
|
partial_scope = {}
|
|
@@ -30,7 +30,6 @@ import pydantic
|
|
|
30
30
|
import pydantic._internal._decorators
|
|
31
31
|
from fastapi import Response
|
|
32
32
|
from fastapi.routing import APIRoute
|
|
33
|
-
from issubclass import issubclass
|
|
34
33
|
from pydantic import BaseModel, Field, RootModel
|
|
35
34
|
from pydantic._internal import _decorators
|
|
36
35
|
from pydantic._internal._decorators import (
|
|
@@ -44,7 +43,7 @@ from pydantic._internal._decorators import (
|
|
|
44
43
|
from pydantic.fields import ComputedFieldInfo, FieldInfo
|
|
45
44
|
from typing_extensions import Doc, Self, _AnnotatedAlias, assert_never
|
|
46
45
|
|
|
47
|
-
from cadwyn._utils import Sentinel, UnionType, fully_unwrap_decorator
|
|
46
|
+
from cadwyn._utils import Sentinel, UnionType, fully_unwrap_decorator, lenient_issubclass
|
|
48
47
|
from cadwyn.exceptions import InvalidGenerationInstructionError
|
|
49
48
|
from cadwyn.structure.common import VersionDate
|
|
50
49
|
from cadwyn.structure.data import ResponseInfo
|
|
@@ -159,9 +158,11 @@ def migrate_response_body(
|
|
|
159
158
|
*,
|
|
160
159
|
latest_body: Any,
|
|
161
160
|
version: VersionDate | str,
|
|
162
|
-
):
|
|
163
|
-
"""Convert the data to a specific version
|
|
164
|
-
|
|
161
|
+
) -> Any:
|
|
162
|
+
"""Convert the data to a specific version
|
|
163
|
+
|
|
164
|
+
Apply all version changes from latest until the passed version in reverse order
|
|
165
|
+
and wrap the result in the correct version of latest_response_model
|
|
165
166
|
"""
|
|
166
167
|
if isinstance(version, str):
|
|
167
168
|
version = date.fromisoformat(version)
|
|
@@ -213,6 +214,10 @@ def _wrap_validator(func: Callable, is_pydantic_v1_style_validator: Any, decorat
|
|
|
213
214
|
# There's an inconsistency in their interfaces so we gotta resort to this
|
|
214
215
|
mode = kwargs.pop("mode", "after")
|
|
215
216
|
kwargs["pre"] = mode != "after"
|
|
217
|
+
if (
|
|
218
|
+
isinstance(decorator_info, RootValidatorDecoratorInfo) and decorator_info.mode == "after"
|
|
219
|
+
): # pragma: no cover # TODO
|
|
220
|
+
kwargs["skip_on_failure"] = True
|
|
216
221
|
if decorator_fields is not None:
|
|
217
222
|
return _PerFieldValidatorWrapper(
|
|
218
223
|
func=func, fields=list(decorator_fields), decorator=actual_decorator, kwargs=kwargs
|
|
@@ -271,7 +276,8 @@ class _PydanticModelWrapper(Generic[_T_PYDANTIC_MODEL]):
|
|
|
271
276
|
fields: Annotated[
|
|
272
277
|
dict["_FieldName", PydanticFieldWrapper],
|
|
273
278
|
Doc(
|
|
274
|
-
"Fields that belong to this model, not to its parents.
|
|
279
|
+
"Fields that belong to this model, not to its parents. "
|
|
280
|
+
"I.e. The ones that were either defined or overridden "
|
|
275
281
|
),
|
|
276
282
|
] = dataclasses.field(repr=False)
|
|
277
283
|
validators: dict[str, _PerFieldValidatorWrapper | _ValidatorWrapper] = dataclasses.field(repr=False)
|
|
@@ -316,7 +322,7 @@ class _PydanticModelWrapper(Generic[_T_PYDANTIC_MODEL]):
|
|
|
316
322
|
for base in self.cls.mro()[1:]:
|
|
317
323
|
if base in schemas:
|
|
318
324
|
parents.append(schemas[base])
|
|
319
|
-
elif
|
|
325
|
+
elif lenient_issubclass(base, BaseModel):
|
|
320
326
|
parents.append(_wrap_pydantic_model(base))
|
|
321
327
|
self._parents = parents
|
|
322
328
|
return parents
|
|
@@ -372,10 +378,9 @@ def is_regular_function(call: Callable):
|
|
|
372
378
|
|
|
373
379
|
|
|
374
380
|
class _CallableWrapper:
|
|
375
|
-
|
|
376
|
-
They are based on putting dependencies (functions) as keys for the dictionary so if we want to be able to
|
|
377
|
-
override the wrapper, we need to make sure that it is equivalent to the original in __hash__ and __eq__
|
|
378
|
-
"""
|
|
381
|
+
# __eq__ and __hash__ are needed to make sure that dependency overrides work correctly.
|
|
382
|
+
# They are based on putting dependencies (functions) as keys for the dictionary so if we want to be able to
|
|
383
|
+
# override the wrapper, we need to make sure that it is equivalent to the original in __hash__ and __eq__
|
|
379
384
|
|
|
380
385
|
def __init__(self, original_callable: Callable) -> None:
|
|
381
386
|
super().__init__()
|
|
@@ -386,11 +391,9 @@ class _CallableWrapper:
|
|
|
386
391
|
|
|
387
392
|
@property
|
|
388
393
|
def __globals__(self):
|
|
389
|
-
|
|
390
|
-
It's supposed to be an attribute on the function but we use it as property to prevent python
|
|
391
|
-
from trying to pickle globals when we deepcopy this wrapper
|
|
392
|
-
"""
|
|
393
|
-
#
|
|
394
|
+
# FastAPI uses __globals__ to resolve forward references in type hints
|
|
395
|
+
# It's supposed to be an attribute on the function but we use it as property to prevent python
|
|
396
|
+
# from trying to pickle globals when we deepcopy this wrapper
|
|
394
397
|
return self._original_callable.__globals__
|
|
395
398
|
|
|
396
399
|
def __call__(self, *args: Any, **kwargs: Any):
|
|
@@ -420,8 +423,7 @@ class _AnnotationTransformer:
|
|
|
420
423
|
)
|
|
421
424
|
|
|
422
425
|
def change_version_of_annotation(self, annotation: Any) -> Any:
|
|
423
|
-
"""Recursively go through all annotations and change them to the
|
|
424
|
-
annotations corresponding to the version passed.
|
|
426
|
+
"""Recursively go through all annotations and change them to annotations corresponding to the version passed.
|
|
425
427
|
|
|
426
428
|
So if we had a annotation "UserResponse" from "head" version, and we passed version of "2022-11-16", it would
|
|
427
429
|
replace "UserResponse" with the the same class but from the "2022-11-16" version.
|
|
@@ -503,7 +505,7 @@ class _AnnotationTransformer:
|
|
|
503
505
|
return annotation
|
|
504
506
|
|
|
505
507
|
def _change_version_of_type(self, annotation: type):
|
|
506
|
-
if
|
|
508
|
+
if lenient_issubclass(annotation, BaseModel | Enum):
|
|
507
509
|
return self.generator[annotation]
|
|
508
510
|
else:
|
|
509
511
|
return annotation
|
|
@@ -607,7 +609,7 @@ def _add_request_and_response_params(route: APIRoute):
|
|
|
607
609
|
|
|
608
610
|
@final
|
|
609
611
|
class SchemaGenerator:
|
|
610
|
-
__slots__ = "annotation_transformer", "
|
|
612
|
+
__slots__ = "annotation_transformer", "concrete_models", "model_bundle"
|
|
611
613
|
|
|
612
614
|
def __init__(self, model_bundle: _ModelBundle) -> None:
|
|
613
615
|
self.annotation_transformer = _AnnotationTransformer(self)
|
|
@@ -619,7 +621,11 @@ class SchemaGenerator:
|
|
|
619
621
|
}
|
|
620
622
|
|
|
621
623
|
def __getitem__(self, model: type[_T_ANY_MODEL], /) -> type[_T_ANY_MODEL]:
|
|
622
|
-
if
|
|
624
|
+
if (
|
|
625
|
+
not isinstance(model, type)
|
|
626
|
+
or not lenient_issubclass(model, BaseModel | Enum)
|
|
627
|
+
or model in (BaseModel, RootModel)
|
|
628
|
+
):
|
|
623
629
|
return model
|
|
624
630
|
model = _unwrap_model(model)
|
|
625
631
|
|
|
@@ -648,10 +654,10 @@ class SchemaGenerator:
|
|
|
648
654
|
elif model in self.model_bundle.enums:
|
|
649
655
|
return self.model_bundle.enums[model]
|
|
650
656
|
|
|
651
|
-
if
|
|
657
|
+
if lenient_issubclass(model, BaseModel):
|
|
652
658
|
wrapper = _wrap_pydantic_model(model)
|
|
653
659
|
self.model_bundle.schemas[model] = wrapper
|
|
654
|
-
elif
|
|
660
|
+
elif lenient_issubclass(model, Enum):
|
|
655
661
|
wrapper = _EnumWrapper(model)
|
|
656
662
|
self.model_bundle.enums[model] = wrapper
|
|
657
663
|
else:
|