Skip to content

Commit 4042d09

Browse files
committed
Merge branch 'main' into docs-fastapi-lifespan-v2
2 parents 4072384 + 349bc73 commit 4042d09

File tree

327 files changed

+2500
-17318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+2500
-17318
lines changed

.github/workflows/build-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ jobs:
6565
pyproject.toml
6666
- name: Install docs extras
6767
run: uv pip install -r requirements-docs.txt
68-
- uses: actions/cache@v4
68+
- uses: actions/cache@v5
6969
with:
7070
key: mkdocs-cards-${{ github.ref }}
7171
path: .cache
7272
- name: Verify README
7373
run: python ./scripts/docs.py verify-readme
7474
- name: Build Docs
7575
run: python ./scripts/docs.py build
76-
- uses: actions/upload-artifact@v5
76+
- uses: actions/upload-artifact@v6
7777
with:
7878
name: docs-site
7979
path: ./site/**

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: |
5050
rm -rf ./site
5151
mkdir ./site
52-
- uses: actions/download-artifact@v6
52+
- uses: actions/download-artifact@v7
5353
with:
5454
path: ./site/
5555
pattern: docs-site

.github/workflows/pre-commit.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
env:
10+
# Forks and Dependabot don't have access to secrets
11+
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
12+
13+
jobs:
14+
pre-commit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Dump GitHub context
18+
env:
19+
GITHUB_CONTEXT: ${{ toJson(github) }}
20+
run: echo "$GITHUB_CONTEXT"
21+
- uses: actions/checkout@v6
22+
name: Checkout PR for own repo
23+
if: env.HAS_SECRETS == 'true'
24+
with:
25+
# To be able to commit it needs to fetch the head of the branch, not the
26+
# merge commit
27+
ref: ${{ github.head_ref }}
28+
# And it needs the full history to be able to compute diffs
29+
fetch-depth: 0
30+
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
31+
token: ${{ secrets.PRE_COMMIT }}
32+
# pre-commit lite ci needs the default checkout configs to work
33+
- uses: actions/checkout@v6
34+
name: Checkout PR for fork
35+
if: env.HAS_SECRETS == 'false'
36+
with:
37+
# To be able to commit it needs the head branch of the PR, the remote one
38+
ref: ${{ github.event.pull_request.head.sha }}
39+
fetch-depth: 0
40+
- name: Set up Python
41+
uses: actions/setup-python@v6
42+
with:
43+
python-version: "3.14"
44+
- name: Setup uv
45+
uses: astral-sh/setup-uv@v7
46+
with:
47+
cache-dependency-glob: |
48+
requirements**.txt
49+
pyproject.toml
50+
uv.lock
51+
- name: Install Dependencies
52+
run: |
53+
uv venv
54+
uv pip install -r requirements.txt
55+
- name: Run prek - pre-commit
56+
id: precommit
57+
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
58+
continue-on-error: true
59+
- name: Commit and push changes
60+
if: env.HAS_SECRETS == 'true'
61+
run: |
62+
git config user.name "github-actions[bot]"
63+
git config user.email "github-actions[bot]@users.noreply.github.com"
64+
git add -A
65+
if git diff --staged --quiet; then
66+
echo "No changes to commit"
67+
else
68+
git commit -m "🎨 Auto format"
69+
git push
70+
fi
71+
- uses: pre-commit-ci/[email protected]
72+
if: env.HAS_SECRETS == 'false'
73+
with:
74+
msg: 🎨 Auto format
75+
- name: Error out on pre-commit errors
76+
if: steps.precommit.outcome == 'failure'
77+
run: exit 1
78+
79+
# https://github.com/marketplace/actions/alls-green#why
80+
pre-commit-alls-green: # This job does nothing and is only used for the branch protection
81+
if: always()
82+
needs:
83+
- pre-commit
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Dump GitHub context
87+
env:
88+
GITHUB_CONTEXT: ${{ toJson(github) }}
89+
run: echo "$GITHUB_CONTEXT"
90+
- name: Decide whether the needed jobs succeeded or failed
91+
uses: re-actors/alls-green@release/v1
92+
with:
93+
jobs: ${{ toJSON(needs) }}

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
requirements**.txt
2727
pyproject.toml
2828
- run: uv pip install -r requirements-github-actions.txt
29-
- uses: actions/download-artifact@v6
29+
- uses: actions/download-artifact@v7
3030
with:
3131
name: coverage-html
3232
path: htmlcov

.github/workflows/test.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
pydantic-version:
3131
- pydantic-v2
3232
include:
33-
- os: macos-latest
34-
python-version: "3.8"
35-
pydantic-version: pydantic-v1
3633
- os: windows-latest
3734
python-version: "3.9"
3835
pydantic-version: pydantic-v2
@@ -81,17 +78,14 @@ jobs:
8178
- name: Install Pydantic v2
8279
if: matrix.pydantic-version == 'pydantic-v2'
8380
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
84-
- name: Lint
85-
if: matrix.pydantic-version == 'pydantic-v2' && matrix.python-version != '3.8'
86-
run: bash scripts/lint.sh
8781
- run: mkdir coverage
8882
- name: Test
8983
run: bash scripts/test.sh
9084
env:
9185
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
9286
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
9387
- name: Store coverage files
94-
uses: actions/upload-artifact@v5
88+
uses: actions/upload-artifact@v6
9589
with:
9690
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
9791
path: coverage
@@ -115,7 +109,7 @@ jobs:
115109
requirements**.txt
116110
pyproject.toml
117111
- name: Get coverage files
118-
uses: actions/download-artifact@v6
112+
uses: actions/download-artifact@v7
119113
with:
120114
pattern: coverage-*
121115
path: coverage
@@ -126,7 +120,7 @@ jobs:
126120
- run: coverage combine coverage
127121
- run: coverage html --title "Coverage for ${{ github.sha }}"
128122
- name: Store coverage HTML
129-
uses: actions/upload-artifact@v5
123+
uses: actions/upload-artifact@v6
130124
with:
131125
name: coverage-html
132126
path: htmlcov

.pre-commit-config.yaml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3-
default_language_version:
4-
python: python3.10
53
repos:
6-
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
75
rev: v6.0.0
86
hooks:
9-
- id: check-added-large-files
10-
- id: check-toml
11-
- id: check-yaml
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
1210
args:
13-
- --unsafe
14-
- id: end-of-file-fixer
15-
- id: trailing-whitespace
16-
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.14.8
11+
- --unsafe
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
15+
- repo: local
1816
hooks:
19-
- id: ruff
20-
args:
21-
- --fix
22-
- id: ruff-format
23-
ci:
24-
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
25-
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
17+
- id: local-ruff-check
18+
name: ruff check
19+
entry: uv run ruff check --force-exclude --fix --exit-non-zero-on-fix
20+
require_serial: true
21+
language: unsupported
22+
types: [python]
23+
24+
- id: local-ruff-format
25+
name: ruff format
26+
entry: uv run ruff format --force-exclude --exit-non-zero-on-format
27+
require_serial: true
28+
language: unsupported
29+
types: [python]
30+
31+
- id: generate-select
32+
language: unsupported
33+
name: generate-select
34+
entry: uv run ./scripts/generate_select.py
35+
files: ^scripts/generate_select\.py|sqlmodel/sql/_expression_select_gen\.py\.jinja2$

docs/management-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ A PR should have a specific use case that it is solving.
9090
* If the PR is for a feature, it should have docs.
9191
* Unless it's a feature we want to discourage, like support for a corner case that we don't want users to use.
9292
* The docs should include a source example file, not write Python directly in Markdown.
93-
* If the source example(s) file can have different syntax for Python 3.8, 3.9, 3.10, there should be different versions of the file, and they should be shown in tabs in the docs.
93+
* If the source example(s) file can have different syntax for different Python versions, there should be different versions of the file, and they should be shown in tabs in the docs.
9494
* There should be tests testing the source example.
9595
* Before the PR is applied, the new tests should fail.
9696
* After applying the PR, the new tests should pass.

docs/release-notes.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@
22

33
## Latest Changes
44

5+
### Internal
6+
7+
* ⬆ Bump dirty-equals from 0.9.0 to 0.11. PR [#1649](https://github.com/fastapi/sqlmodel/pull/1649) by [@dependabot[bot]](https://github.com/apps/dependabot).
8+
* ⬆ Bump mkdocs-material from 9.7.0 to 9.7.1. PR [#1690](https://github.com/fastapi/sqlmodel/pull/1690) by [@dependabot[bot]](https://github.com/apps/dependabot).
9+
* ⬆ Bump typer from 0.20.1 to 0.21.0. PR [#1694](https://github.com/fastapi/sqlmodel/pull/1694) by [@dependabot[bot]](https://github.com/apps/dependabot).
10+
* 📌 Relax `prek` version pin to `>=0.2.24,<1.0.0`. PR [#1698](https://github.com/fastapi/sqlmodel/pull/1698) by [@YuriiMotov](https://github.com/YuriiMotov).
11+
12+
## 0.0.30
13+
14+
### Breaking Changes
15+
16+
* ➖ Drop support for Python 3.8. PR [#1696](https://github.com/fastapi/sqlmodel/pull/1696) by [@tiangolo](https://github.com/tiangolo).
17+
18+
### Docs
19+
20+
* ➖ Drop support for Python 3.8 in CI and docs. PR [#1695](https://github.com/fastapi/sqlmodel/pull/1695) by [@YuriiMotov](https://github.com/YuriiMotov) and [@tiangolo](https://github.com/tiangolo).
21+
22+
### Internal
23+
24+
* 🔧 Update pre-commit, generate select on pre-commit, use local Ruff. PR [#1697](https://github.com/fastapi/sqlmodel/pull/1697) by [@tiangolo](https://github.com/tiangolo).
25+
* ⬆ Bump actions/checkout from 5 to 6. PR [#1692](https://github.com/fastapi/sqlmodel/pull/1692) by [@dependabot[bot]](https://github.com/apps/dependabot).
26+
* 👷 Add pre-commit workflow. PR [#1684](https://github.com/fastapi/sqlmodel/pull/1684) by [@YuriiMotov](https://github.com/YuriiMotov).
27+
* ✅ Simplify tests for code examples, one test file for multiple variants. PR [#1664](https://github.com/fastapi/sqlmodel/pull/1664) by [@YuriiMotov](https://github.com/YuriiMotov).
28+
*[pre-commit.ci] pre-commit autoupdate. PR [#1677](https://github.com/fastapi/sqlmodel/pull/1677) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
29+
* ⬆ Bump actions/download-artifact from 6 to 7. PR [#1676](https://github.com/fastapi/sqlmodel/pull/1676) by [@dependabot[bot]](https://github.com/apps/dependabot).
30+
* ⬆ Bump actions/cache from 4 to 5. PR [#1673](https://github.com/fastapi/sqlmodel/pull/1673) by [@dependabot[bot]](https://github.com/apps/dependabot).
31+
* ⬆ Bump markdown-include-variants from 0.0.5 to 0.0.8. PR [#1674](https://github.com/fastapi/sqlmodel/pull/1674) by [@dependabot[bot]](https://github.com/apps/dependabot).
32+
* ⬆ Bump actions/upload-artifact from 5 to 6. PR [#1675](https://github.com/fastapi/sqlmodel/pull/1675) by [@dependabot[bot]](https://github.com/apps/dependabot).
33+
* ⬆ Bump mypy from 1.18.2 to 1.19.1. PR [#1679](https://github.com/fastapi/sqlmodel/pull/1679) by [@dependabot[bot]](https://github.com/apps/dependabot).
34+
* ⬆ Bump typer from 0.20.0 to 0.20.1. PR [#1685](https://github.com/fastapi/sqlmodel/pull/1685) by [@dependabot[bot]](https://github.com/apps/dependabot).
35+
* ⬆ Bump ruff from 0.14.8 to 0.14.10. PR [#1681](https://github.com/fastapi/sqlmodel/pull/1681) by [@dependabot[bot]](https://github.com/apps/dependabot).
36+
37+
## 0.0.29
38+
39+
### Fixes
40+
41+
* 🐛 Fix `alias` support for Pydantic v2. PR [#1577](https://github.com/fastapi/sqlmodel/pull/1577) by [@ravishan16](https://github.com/ravishan16).
42+
43+
## 0.0.28
44+
45+
### Fixes
46+
47+
* 🐛 Fix `RuntimeError: dictionary changed size during iteration` in `sqlmodel_update()`. PR [#997](https://github.com/fastapi/sqlmodel/pull/997) by [@BartSchuurmans](https://github.com/BartSchuurmans).
48+
549
### Docs
650

751
* 💅 Update CSS to explicitly use emoji font. PR [#1658](https://github.com/fastapi/sqlmodel/pull/1658) by [@tiangolo](https://github.com/tiangolo).
@@ -10,6 +54,7 @@
1054

1155
### Internal
1256

57+
* 📌 Pin FastAPI in tests to 0.125.0 while dropping support for Python 3.8. PR [#1689](https://github.com/fastapi/sqlmodel/pull/1689) by [@tiangolo](https://github.com/tiangolo).
1358
* 👷 Configure coverage, error on main tests, don't wait for Smokeshow. PR [#1683](https://github.com/fastapi/sqlmodel/pull/1683) by [@YuriiMotov](https://github.com/YuriiMotov).
1459
* 👷 Run Smokeshow always, even on test failures. PR [#1682](https://github.com/fastapi/sqlmodel/pull/1682) by [@YuriiMotov](https://github.com/YuriiMotov).
1560
* ⬆ Bump ruff from 0.14.6 to 0.14.8. PR [#1667](https://github.com/fastapi/sqlmodel/pull/1667) by [@dependabot[bot]](https://github.com/apps/dependabot).

docs/tutorial/automatic-id-none-refresh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ And as we created the **engine** with `echo=True`, we can see the SQL statements
342342

343343
////
344344

345-
//// tab | Python 3.8+
345+
//// tab | Python 3.9+
346346

347347
```Python
348-
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
348+
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002_py39.py!}
349349
```
350350

351351
{!./docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md!}

docs/tutorial/code-structure.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ We can use these relative imports because, for example, in the file `app.py` (th
6767

6868
You could put all the database Models in a single Python module (a single Python file), for example `models.py`:
6969

70-
```Python
71-
{!./docs_src/tutorial/code_structure/tutorial001/models.py!}
72-
```
70+
{* ./docs_src/tutorial/code_structure/tutorial001_py310/models.py *}
7371

7472
This way, you wouldn't have to deal with circular imports for other models.
7573

@@ -79,19 +77,15 @@ And then you could import the models from this file/module in any other file/mod
7977

8078
Then you could put the code creating the **engine** and the function to create all the tables (if you are not using migrations) in another file `database.py`:
8179

82-
```Python
83-
{!./docs_src/tutorial/code_structure/tutorial001/database.py!}
84-
```
80+
{* ./docs_src/tutorial/code_structure/tutorial001_py310/database.py *}
8581

8682
This file would also be imported by your application code, to use the shared **engine** and to get and call the function `create_db_and_tables()`.
8783

8884
### Application File
8985

9086
Finally, you could put the code to create the **app** in another file `app.py`:
9187

92-
```Python hl_lines="3-4"
93-
{!./docs_src/tutorial/code_structure/tutorial001/app.py!}
94-
```
88+
{* ./docs_src/tutorial/code_structure/tutorial001_py310/app.py hl[3:4] *}
9589

9690
Here we import the models, the engine, and the function to create all the tables and then we can use them all internally.
9791

@@ -207,29 +201,23 @@ So, we can use it in an `if` block and import things inside the `if` block. And
207201

208202
Using that trick of `TYPE_CHECKING` we can "import" the `Team` in `hero_model.py`:
209203

210-
```Python hl_lines="1 5-6 16"
211-
{!./docs_src/tutorial/code_structure/tutorial002/hero_model.py!}
212-
```
204+
{* ./docs_src/tutorial/code_structure/tutorial002_py310/hero_model.py hl[1,5:6,16] *}
213205

214206
Have in mind that now we *have* to put the annotation of `Team` as a string: `"Team"`, so that Python doesn't have errors at runtime.
215207

216208
### Team Model File
217209

218210
We use the same trick in the `team_model.py` file:
219211

220-
```Python hl_lines="1 5-6 14"
221-
{!./docs_src/tutorial/code_structure/tutorial002/team_model.py!}
222-
```
212+
{* ./docs_src/tutorial/code_structure/tutorial002_py310/team_model.py hl[1,5:6,14] *}
223213

224214
Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps working. 🎉
225215

226216
### App File
227217

228218
Now, just for completeness, the `app.py` file would import the models from both modules:
229219

230-
```Python hl_lines="4-5 10 12-14"
231-
{!./docs_src/tutorial/code_structure/tutorial002/app.py!}
232-
```
220+
{* ./docs_src/tutorial/code_structure/tutorial002_py310/app.py hl[4:5,10,12:14] *}
233221

234222
And of course, all the tricks with `TYPE_CHECKING` and type annotations in strings are **only needed in the files with circular imports**.
235223

0 commit comments

Comments
 (0)