Drop support for Python 3.8 in CI and docs (#1695)

Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
This commit is contained in:
Sebastián Ramírez
2025-12-26 03:03:06 -08:00
committed by GitHub
parent d7b596b1dd
commit afc0c324cf
207 changed files with 186 additions and 3738 deletions

View File

@@ -342,10 +342,10 @@ And as we created the **engine** with `echo=True`, we can see the SQL statements
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002_py39.py!}
```
{!./docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md!}

View File

@@ -67,9 +67,7 @@ We can use these relative imports because, for example, in the file `app.py` (th
You could put all the database Models in a single Python module (a single Python file), for example `models.py`:
```Python
{!./docs_src/tutorial/code_structure/tutorial001/models.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial001_py310/models.py *}
This way, you wouldn't have to deal with circular imports for other models.
@@ -79,9 +77,7 @@ And then you could import the models from this file/module in any other file/mod
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`:
```Python
{!./docs_src/tutorial/code_structure/tutorial001/database.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial001_py310/database.py *}
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()`.
@@ -89,9 +85,7 @@ This file would also be imported by your application code, to use the shared **e
Finally, you could put the code to create the **app** in another file `app.py`:
```Python hl_lines="3-4"
{!./docs_src/tutorial/code_structure/tutorial001/app.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial001_py310/app.py hl[3:4] *}
Here we import the models, the engine, and the function to create all the tables and then we can use them all internally.
@@ -207,9 +201,7 @@ So, we can use it in an `if` block and import things inside the `if` block. And
Using that trick of `TYPE_CHECKING` we can "import" the `Team` in `hero_model.py`:
```Python hl_lines="1 5-6 16"
{!./docs_src/tutorial/code_structure/tutorial002/hero_model.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial002_py310/hero_model.py hl[1,5:6,16] *}
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.
@@ -217,9 +209,7 @@ Have in mind that now we *have* to put the annotation of `Team` as a string: `"T
We use the same trick in the `team_model.py` file:
```Python hl_lines="1 5-6 14"
{!./docs_src/tutorial/code_structure/tutorial002/team_model.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial002_py310/team_model.py hl[1,5:6,14] *}
Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps working. 🎉
@@ -227,9 +217,7 @@ Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps
Now, just for completeness, the `app.py` file would import the models from both modules:
```Python hl_lines="4-5 10 12-14"
{!./docs_src/tutorial/code_structure/tutorial002/app.py!}
```
{* ./docs_src/tutorial/code_structure/tutorial002_py310/app.py hl[4:5,10,12:14] *}
And of course, all the tricks with `TYPE_CHECKING` and type annotations in strings are **only needed in the files with circular imports**.

View File

@@ -562,10 +562,10 @@ Now, let's give the code a final look:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{.python .annotate}
{!./docs_src/tutorial/create_db_and_table/tutorial003.py!}
{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py!}
```
{!./docs_src/tutorial/create_db_and_table/annotations/en/tutorial003.md!}

View File

@@ -227,10 +227,10 @@ Now let's review all that code:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{ .python .annotate hl_lines="72-90" }
{!./docs_src/tutorial/delete/tutorial002.py!}
{!./docs_src/tutorial/delete/tutorial002_py39.py!}
```
{!./docs_src/tutorial/delete/annotations/en/tutorial002.md!}

View File

@@ -14,7 +14,7 @@ We will use the application with the hero models, but without team models, and w
Now we will see how useful it is to have this session dependency. ✨
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/main.py ln[0] *}
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/main.py ln[0] *}
## File Structure
@@ -53,16 +53,16 @@ $ pip install requests pytest
Let's start with a simple test, with just the basic test code we need the check that the **FastAPI** application is creating a new hero correctly.
```{ .python .annotate }
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:1-7]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:1-7]!}
# Some code here omitted, we will see it later 👈
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:20-24]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:20-24]!}
# Some code here omitted, we will see it later 👈
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:26-32]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:26-32]!}
# Code below omitted 👇
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_001.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_001.md!}
/// tip
@@ -103,14 +103,14 @@ We will override it to use a different **session** object just for the tests.
That way we protect the production database and we have better control of the data we are testing.
```{ .python .annotate hl_lines="4 9-10 12 19" }
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py[ln:1-7]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_002.py[ln:1-7]!}
# Some code here omitted, we will see it later 👈
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py[ln:15-32]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_002.py[ln:15-32]!}
# Code below omitted 👇
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_002.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_002.md!}
/// tip
@@ -131,10 +131,10 @@ sqlite:///testing.db
So, the testing database will be in the file `testing.db`.
``` { .python .annotate hl_lines="4 8-11 13 16 33"}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_003.py!}
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_003.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_003.md!}
### Import Table Models
@@ -187,12 +187,12 @@ Let's update our code to use the in-memory database.
We just have to change a couple of parameters in the **engine**.
```{ .python .annotate hl_lines="3 9-13"}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py[ln:1-13]!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_004.py[ln:1-13]!}
# Code below omitted 👇
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_004.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_004.md!}
/// tip
@@ -235,10 +235,10 @@ You can read more about them in the <a href="https://docs.pytest.org/en/6.2.x/fi
Let's see the first code example with a fixture:
``` { .python .annotate }
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_005.py!}
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_005.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_005.md!}
/// tip
@@ -275,10 +275,10 @@ Each **pytest** fixture (the same way as **FastAPI** dependencies), can require
So, we can create a **client fixture** that will be used in all the tests, and it will itself require the **session fixture**.
``` { .python .annotate hl_lines="19-28 31" }
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_006.py!}
```
{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_006.md!}
{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_006.md!}
/// tip
@@ -298,7 +298,7 @@ But normally we will create **lots of other test functions**. And now all the bo
Let's add some more tests:
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[30:58] hl[30,49] *}
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[30:58] hl[30,49] *}
/// tip
@@ -318,7 +318,7 @@ For these examples, **that would have been simpler**, there's no need to separat
But for the next test function, we will require **both fixtures**, the **client** and the **session**.
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[1:6,61:81] hl[6,61] *}
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[1:6,61:81] hl[6,61] *}
In this test function, we want to check that the *path operation* to **read a list of heroes** actually sends us heroes.
@@ -344,7 +344,7 @@ The function for the **client fixture** and the actual testing function will **b
Using the same ideas, requiring the fixtures, creating data that we need for the tests, etc., we can now add the rest of the tests. They look quite similar to what we have done up to now.
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[84:125] hl[84,99,114] *}
{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[84:125] hl[84,99,114] *}
## Run the Tests

View File

@@ -39,14 +39,14 @@ This is the code we had to create the database and table, nothing new here:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{.python .annotate hl_lines="22" }
{!./docs_src/tutorial/create_db_and_table/tutorial003.py[ln:1-20]!}
{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py[ln:1-20]!}
# More code here later 👈
{!./docs_src/tutorial/create_db_and_table/tutorial003.py[ln:23-24]!}
{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py[ln:23-24]!}
```
{!./docs_src/tutorial/create_db_and_table/annotations/en/tutorial003.md!}
@@ -343,10 +343,10 @@ Let's focus on the new code:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{.python .annotate }
{!./docs_src/tutorial/insert/tutorial003.py!}
{!./docs_src/tutorial/insert/tutorial003_py39.py!}
```
{!./docs_src/tutorial/insert/annotations/en/tutorial003.md!}

View File

@@ -273,10 +273,10 @@ Let's review the code up to this point:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{ .python .annotate }
{!./docs_src/tutorial/select/tutorial002.py!}
{!./docs_src/tutorial/select/tutorial002_py39.py!}
```
{!./docs_src/tutorial/select/annotations/en/tutorial002.md!}

View File

@@ -236,10 +236,10 @@ Now let's review all that code:
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{ .python .annotate hl_lines="44-55" }
{!./docs_src/tutorial/update/tutorial002.py!}
{!./docs_src/tutorial/update/tutorial002_py39.py!}
```
{!./docs_src/tutorial/update/annotations/en/tutorial002.md!}
@@ -272,12 +272,12 @@ This also means that you can update several fields (attributes, columns) at once
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```{ .python .annotate hl_lines="15-17 19-21 23" }
# Code above omitted 👆
{!./docs_src/tutorial/update/tutorial004.py[ln:44-70]!}
{!./docs_src/tutorial/update/tutorial004_py39.py[ln:44-70]!}
# Code below omitted 👇
```
@@ -296,10 +296,10 @@ This also means that you can update several fields (attributes, columns) at once
////
//// tab | Python 3.8+
//// tab | Python 3.9+
```Python
{!./docs_src/tutorial/update/tutorial004.py!}
{!./docs_src/tutorial/update/tutorial004_py39.py!}
```
////