]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update order of examples, latest Python version first, and simplify version tab...
authorSebastián Ramírez <tiangolo@gmail.com>
Sat, 18 Mar 2023 16:16:02 +0000 (17:16 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Mar 2023 16:16:02 +0000 (17:16 +0100)
* 📝 Simplify names in Python versions in tabs in docs

* 📝 Update docs for Types Intro, explain Python 3.6+, Python 3.9+, Python 3.10+

* 📝 Re-order all Python examples, show latest Python versions first

55 files changed:
docs/en/docs/advanced/additional-status-codes.md
docs/en/docs/advanced/advanced-dependencies.md
docs/en/docs/advanced/generate-clients.md
docs/en/docs/advanced/security/http-basic-auth.md
docs/en/docs/advanced/security/oauth2-scopes.md
docs/en/docs/advanced/settings.md
docs/en/docs/advanced/testing-dependencies.md
docs/en/docs/advanced/websockets.md
docs/en/docs/python-types.md
docs/en/docs/tutorial/background-tasks.md
docs/en/docs/tutorial/bigger-applications.md
docs/en/docs/tutorial/body-fields.md
docs/en/docs/tutorial/body-multiple-params.md
docs/en/docs/tutorial/body-nested-models.md
docs/en/docs/tutorial/body-updates.md
docs/en/docs/tutorial/body.md
docs/en/docs/tutorial/cookie-params.md
docs/en/docs/tutorial/dependencies/classes-as-dependencies.md
docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
docs/en/docs/tutorial/dependencies/dependencies-with-yield.md
docs/en/docs/tutorial/dependencies/global-dependencies.md
docs/en/docs/tutorial/dependencies/index.md
docs/en/docs/tutorial/dependencies/sub-dependencies.md
docs/en/docs/tutorial/encoder.md
docs/en/docs/tutorial/extra-data-types.md
docs/en/docs/tutorial/extra-models.md
docs/en/docs/tutorial/header-params.md
docs/en/docs/tutorial/path-operation-configuration.md
docs/en/docs/tutorial/path-params-numeric-validations.md
docs/en/docs/tutorial/query-params-str-validations.md
docs/en/docs/tutorial/query-params.md
docs/en/docs/tutorial/request-files.md
docs/en/docs/tutorial/request-forms-and-files.md
docs/en/docs/tutorial/request-forms.md
docs/en/docs/tutorial/response-model.md
docs/en/docs/tutorial/schema-extra-example.md
docs/en/docs/tutorial/security/first-steps.md
docs/en/docs/tutorial/security/get-current-user.md
docs/en/docs/tutorial/security/oauth2-jwt.md
docs/en/docs/tutorial/security/simple-oauth2.md
docs/en/docs/tutorial/sql-databases.md
docs/en/docs/tutorial/testing.md
docs/ja/docs/tutorial/testing.md
docs/pt/docs/tutorial/body-multiple-params.md
docs/pt/docs/tutorial/encoder.md
docs/pt/docs/tutorial/header-params.md
docs/pt/docs/tutorial/path-params-numeric-validations.md
docs/pt/docs/tutorial/query-params.md
docs/ru/docs/tutorial/background-tasks.md
docs/ru/docs/tutorial/body-fields.md
docs/ru/docs/tutorial/cookie-params.md
docs/zh/docs/tutorial/dependencies/classes-as-dependencies.md
docs/zh/docs/tutorial/encoder.md
docs/zh/docs/tutorial/request-files.md
docs/zh/docs/tutorial/sql-databases.md

index d287f861a991bbf5d8f0810b49aee1eee2d23d08..b0d8d7bd5a64180cb8c36aedd3462daaed629a6d 100644 (file)
@@ -14,40 +14,40 @@ But you also want it to accept new items. And when the items didn't exist before
 
 To achieve that, import `JSONResponse`, and return your content there directly, setting the `status_code` that you want:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4  26"
-    {!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
+    ```Python hl_lines="4  25"
+    {!> ../../../docs_src/additional_status_codes/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="4  25"
     {!> ../../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  25"
-    {!> ../../../docs_src/additional_status_codes/tutorial001_an_py310.py!}
+    ```Python hl_lines="4  26"
+    {!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="4  25"
-    {!> ../../../docs_src/additional_status_codes/tutorial001.py!}
+    ```Python hl_lines="2  23"
+    {!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="2  23"
-    {!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
+    ```Python hl_lines="4  25"
+    {!> ../../../docs_src/additional_status_codes/tutorial001.py!}
     ```
 
 !!! warning
index 97621fcf9643909153cb66474ba5b8488df05905..9a25d2c64dbcd8ef1a34f706fc1b43b50e74e15d 100644 (file)
@@ -18,19 +18,19 @@ Not the class itself (which is already a callable), but an instance of that clas
 
 To do that, we declare a method `__call__`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -45,19 +45,19 @@ In this case, this `__call__` is what **FastAPI** will use to check for addition
 
 And now, we can use `__init__` to declare the parameters of the instance that we can use to "parameterize" the dependency:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -72,19 +72,19 @@ In this case, **FastAPI** won't ever touch or care about `__init__`, we will use
 
 We could create an instance of this class with:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -107,19 +107,19 @@ checker(q="somequery")
 
 ...and pass whatever that returns as the value of the dependency in our *path operation function* as the parameter `fixed_content_included`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="21"
-    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
+    ```Python hl_lines="21"
+    {!> ../../../docs_src/dependencies/tutorial011_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index f31a248d0b0deff22b705c8ec71428a78af5b68d..f62c0b57c181847e889ea62a55af9f31370f44ba 100644 (file)
@@ -16,16 +16,16 @@ If you are building a **frontend**, a very interesting alternative is <a href="h
 
 Let's start with a simple FastAPI application:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9-11  14-15  18  19  23"
-    {!> ../../../docs_src/generate_clients/tutorial001.py!}
+    ```Python hl_lines="7-9  12-13  16-17  21"
+    {!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7-9  12-13  16-17  21"
-    {!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
+    ```Python hl_lines="9-11  14-15  18  19  23"
+    {!> ../../../docs_src/generate_clients/tutorial001.py!}
     ```
 
 Notice that the *path operations* define the models they use for request payload and response payload, using the models `Item` and `ResponseMessage`.
@@ -128,17 +128,16 @@ In many cases your FastAPI app will be bigger, and you will probably use tags to
 
 For example, you could have a section for **items** and another section for **users**, and they could be separated by tags:
 
+=== "Python 3.9+"
 
-=== "Python 3.6 and above"
-
-    ```Python hl_lines="23  28  36"
-    {!> ../../../docs_src/generate_clients/tutorial002.py!}
+    ```Python hl_lines="21  26  34"
+    {!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="21  26  34"
-    {!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
+    ```Python hl_lines="23  28  36"
+    {!> ../../../docs_src/generate_clients/tutorial002.py!}
     ```
 
 ### Generate a TypeScript Client with Tags
@@ -186,16 +185,16 @@ For example, here it is using the first tag (you will probably have only one tag
 
 You can then pass that custom function to **FastAPI** as the `generate_unique_id_function` parameter:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8-9  12"
-    {!> ../../../docs_src/generate_clients/tutorial003.py!}
+    ```Python hl_lines="6-7  10"
+    {!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6-7  10"
-    {!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
+    ```Python hl_lines="8-9  12"
+    {!> ../../../docs_src/generate_clients/tutorial003.py!}
     ```
 
 ### Generate a TypeScript Client with Custom Operation IDs
index a9ce3b1efd377c05080b375cc9f8fed0b37e932b..f7776e73db404e6054cd26e2f8cf12adb8cc8f0a 100644 (file)
@@ -20,19 +20,19 @@ Then, when you type that username and password, the browser sends them in the he
 * It returns an object of type `HTTPBasicCredentials`:
     * It contains the `username` and `password` sent.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="2  7  11"
-    {!> ../../../docs_src/security/tutorial006_an.py!}
+    ```Python hl_lines="4  8  12"
+    {!> ../../../docs_src/security/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  8  12"
-    {!> ../../../docs_src/security/tutorial006_an_py39.py!}
+    ```Python hl_lines="2  7  11"
+    {!> ../../../docs_src/security/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -59,19 +59,19 @@ To handle that, we first convert the `username` and `password` to `bytes` encodi
 
 Then we can use `secrets.compare_digest()` to ensure that `credentials.username` is `"stanleyjobson"`, and that `credentials.password` is `"swordfish"`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="1  12-24"
-    {!> ../../../docs_src/security/tutorial007_an.py!}
+    {!> ../../../docs_src/security/tutorial007_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="1  12-24"
-    {!> ../../../docs_src/security/tutorial007_an_py39.py!}
+    {!> ../../../docs_src/security/tutorial007_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -142,19 +142,19 @@ That way, using `secrets.compare_digest()` in your application code, it will be
 
 After detecting that the credentials are incorrect, return an `HTTPException` with a status code 401 (the same returned when no credentials are provided) and add the header `WWW-Authenticate` to make the browser show the login prompt again:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="26-30"
-    {!> ../../../docs_src/security/tutorial007_an.py!}
+    {!> ../../../docs_src/security/tutorial007_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="26-30"
-    {!> ../../../docs_src/security/tutorial007_an_py39.py!}
+    {!> ../../../docs_src/security/tutorial007_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index c216d7f505c3426b3d43f8ba3032e90d78ad495d..57757ec6c20e2dfe07819ac889d8dc9a66e19f7f 100644 (file)
@@ -56,34 +56,34 @@ They are normally used to declare specific security permissions, for example:
 
 First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md){.internal-link target=_blank}. Now using OAuth2 scopes:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="2  4  8  12  47  65  106  108-116  122-125  129-135  140  156"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="4  8  12  46  64  105  107-115  121-124  128-134  139  155"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="2  4  8  12  46  64  105  107-115  121-124  128-134  139  155"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  8  12  46  64  105  107-115  121-124  128-134  139  155"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="2  4  8  12  47  65  106  108-116  122-125  129-135  140  156"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="2  4  8  12  46  64  105  107-115  121-124  128-134  139  153"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="3  7  11  45  63  104  106-114  120-123  127-133  138  152"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -92,13 +92,13 @@ First, let's quickly see the parts that change from the examples in the main **T
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3  7  11  45  63  104  106-114  120-123  127-133  138  152"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="2  4  8  12  46  64  105  107-115  121-124  128-134  139  153"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 Now let's review those changes step by step.
@@ -109,34 +109,35 @@ The first change is that now we are declaring the OAuth2 security scheme with tw
 
 The `scopes` parameter receives a `dict` with each scope as a key and the description as the value:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="63-66"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="62-65"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="62-65"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="62-65"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="63-66"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="62-65"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="61-64"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -145,13 +146,13 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="61-64"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="62-65"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 Because we are now declaring those scopes, they will show up in the API docs when you log-in/authorize.
@@ -175,34 +176,34 @@ And we return the scopes as part of the JWT token.
 
     But in your application, for security, you should make sure you only add the scopes that the user is actually able to have, or the ones you have predefined.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="156"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="155"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="155"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="155"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="156"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="153"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="152"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -211,13 +212,13 @@ And we return the scopes as part of the JWT token.
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="152"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="153"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 ## Declare scopes in *path operations* and dependencies
@@ -241,34 +242,34 @@ In this case, it requires the scope `me` (it could require more than one scope).
 
     We are doing it here to demonstrate how **FastAPI** handles scopes declared at different levels.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4  140  171"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="4  139  170"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="4  139  170"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  139  170"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="4  140  171"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="4  139  166"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="3  138  165"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -277,13 +278,13 @@ In this case, it requires the scope `me` (it could require more than one scope).
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3  138  165"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="4  139  166"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 !!! info "Technical Details"
@@ -307,34 +308,34 @@ We also declare a special parameter of type `SecurityScopes`, imported from `fas
 
 This `SecurityScopes` class is similar to `Request` (`Request` was used to get the request object directly).
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="8  106"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="8  105"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="8  105"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8  105"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="8  106"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8  105"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="7  104"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -343,13 +344,13 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7  104"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="8  105"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 ## Use the `scopes`
@@ -364,34 +365,34 @@ We create an `HTTPException` that we can re-use (`raise`) later at several point
 
 In this exception, we include the scopes required (if any) as a string separated by spaces (using `scope_str`). We put that string containing the scopes in the `WWW-Authenticate` header (this is part of the spec).
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="106  108-116"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="105  107-115"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="105  107-115"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="105  107-115"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="106  108-116"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="105  107-115"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="104  106-114"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -400,13 +401,13 @@ In this exception, we include the scopes required (if any) as a string separated
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="104  106-114"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="105  107-115"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 ## Verify the `username` and data shape
@@ -423,34 +424,34 @@ Instead of, for example, a `dict`, or something else, as it could break the appl
 
 We also verify that we have a user with that username, and if not, we raise that same exception we created before.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="47  117-128"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="46  116-127"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="46  116-127"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="46  116-127"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="47  117-128"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="46  116-127"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="45  115-126"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -459,13 +460,13 @@ We also verify that we have a user with that username, and if not, we raise that
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="45  115-126"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="46  116-127"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 ## Verify the `scopes`
@@ -474,34 +475,34 @@ We now verify that all the scopes required, by this dependency and all the depen
 
 For this, we use `security_scopes.scopes`, that contains a `list` with all these scopes as `str`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="129-135"
-    {!> ../../../docs_src/security/tutorial005_an.py!}
+    ```Python hl_lines="128-134"
+    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="128-134"
     {!> ../../../docs_src/security/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="128-134"
-    {!> ../../../docs_src/security/tutorial005_an_py310.py!}
+    ```Python hl_lines="129-135"
+    {!> ../../../docs_src/security/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="128-134"
-    {!> ../../../docs_src/security/tutorial005.py!}
+    ```Python hl_lines="127-133"
+    {!> ../../../docs_src/security/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -510,13 +511,13 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
     {!> ../../../docs_src/security/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="127-133"
-    {!> ../../../docs_src/security/tutorial005_py310.py!}
+    ```Python hl_lines="128-134"
+    {!> ../../../docs_src/security/tutorial005.py!}
     ```
 
 ## Dependency tree and scopes
index 52dbdf6fa52ae4574c2d7f0d1e03416687baa737..a29485a2110c164d8c8f50d3cf6d160a2d2d97f1 100644 (file)
@@ -216,19 +216,19 @@ Notice that now we don't create a default instance `settings = Settings()`.
 
 Now we create a dependency that returns a new `config.Settings()`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="6  12-13"
-    {!> ../../../docs_src/settings/app02_an/main.py!}
+    {!> ../../../docs_src/settings/app02_an_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="6  12-13"
-    {!> ../../../docs_src/settings/app02_an_py39/main.py!}
+    {!> ../../../docs_src/settings/app02_an/main.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -244,19 +244,19 @@ Now we create a dependency that returns a new `config.Settings()`.
 
 And then we can require it from the *path operation function* as a dependency and use it anywhere we need it.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="17  19-21"
-    {!> ../../../docs_src/settings/app02_an/main.py!}
+    {!> ../../../docs_src/settings/app02_an_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="17  19-21"
-    {!> ../../../docs_src/settings/app02_an_py39/main.py!}
+    {!> ../../../docs_src/settings/app02_an/main.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -338,19 +338,19 @@ we would create that object for each request, and we would be reading the `.env`
 
 But as we are using the `@lru_cache()` decorator on top, the `Settings` object will be created only once, the first time it's called. ✔️
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="1  11"
-    {!> ../../../docs_src/settings/app03_an/main.py!}
+    {!> ../../../docs_src/settings/app03_an_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="1  11"
-    {!> ../../../docs_src/settings/app03_an_py39/main.py!}
+    {!> ../../../docs_src/settings/app03_an/main.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index c30dccd5d12e56ddfcc9bd2c5393a16bf9d6034d..fecc14d5f3352a358318299e9ff08584a40220f3 100644 (file)
@@ -28,40 +28,40 @@ To override a dependency for testing, you put as a key the original dependency (
 
 And then **FastAPI** will call that override instead of the original dependency.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="29-30  33"
-    {!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
+    ```Python hl_lines="26-27  30"
+    {!> ../../../docs_src/dependency_testing/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="28-29  32"
     {!> ../../../docs_src/dependency_testing/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="26-27  30"
-    {!> ../../../docs_src/dependency_testing/tutorial001_an_py310.py!}
+    ```Python hl_lines="29-30  33"
+    {!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="28-29  32"
-    {!> ../../../docs_src/dependency_testing/tutorial001.py!}
+    ```Python hl_lines="24-25  28"
+    {!> ../../../docs_src/dependency_testing/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="24-25  28"
-    {!> ../../../docs_src/dependency_testing/tutorial001_py310.py!}
+    ```Python hl_lines="28-29  32"
+    {!> ../../../docs_src/dependency_testing/tutorial001.py!}
     ```
 
 !!! tip
index 8df32f4cab11c11c8bfdf9072ed0b588f60d1544..3cdd457361c3a76f61fab8937de74ec521a515f0 100644 (file)
@@ -112,40 +112,40 @@ In WebSocket endpoints you can import from `fastapi` and use:
 
 They work the same way as for other FastAPI endpoints/*path operations*:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="69-70  83"
-    {!> ../../../docs_src/websockets/tutorial002_an.py!}
+    ```Python hl_lines="68-69  82"
+    {!> ../../../docs_src/websockets/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="68-69  82"
     {!> ../../../docs_src/websockets/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="68-69  82"
-    {!> ../../../docs_src/websockets/tutorial002_an_py310.py!}
+    ```Python hl_lines="69-70  83"
+    {!> ../../../docs_src/websockets/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="68-69  81"
-    {!> ../../../docs_src/websockets/tutorial002.py!}
+    ```Python hl_lines="66-67  79"
+    {!> ../../../docs_src/websockets/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="66-67  79"
-    {!> ../../../docs_src/websockets/tutorial002_py310.py!}
+    ```Python hl_lines="68-69  81"
+    {!> ../../../docs_src/websockets/tutorial002.py!}
     ```
 
 !!! info
@@ -185,16 +185,16 @@ With that you can connect the WebSocket and then send and receive messages:
 
 When a WebSocket connection is closed, the `await websocket.receive_text()` will raise a `WebSocketDisconnect` exception, which you can then catch and handle like in this example.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="81-83"
-    {!> ../../../docs_src/websockets/tutorial003.py!}
+    ```Python hl_lines="79-81"
+    {!> ../../../docs_src/websockets/tutorial003_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="79-81"
-    {!> ../../../docs_src/websockets/tutorial003_py39.py!}
+    ```Python hl_lines="81-83"
+    {!> ../../../docs_src/websockets/tutorial003.py!}
     ```
 
 To try it out:
index 7ddfd41f274ea458ad95ae172302a53dc5a9f5b2..693613a36fa8d70d20ac5278e537b13e726a661a 100644 (file)
@@ -158,13 +158,31 @@ The syntax using `typing` is **compatible** with all versions, from Python 3.6 t
 
 As Python advances, **newer versions** come with improved support for these type annotations and in many cases you won't even need to import and use the `typing` module to declare the type annotations.
 
-If you can choose a more recent version of Python for your project, you will be able to take advantage of that extra simplicity. See some examples below.
+If you can choose a more recent version of Python for your project, you will be able to take advantage of that extra simplicity.
+
+In all the docs there are examples compatible with each version of Python (when there's a difference).
+
+For example "**Python 3.6+**" means it's compatible with Python 3.6 or above (including 3.7, 3.8, 3.9, 3.10, etc). And "**Python 3.9+**" means it's compatible with Python 3.9 or above (including 3.10, etc).
+
+If you can use the **latest versions of Python**, use the examples for the latest version, those will have the **best and simplest syntax**, for example, "**Python 3.10+**".
 
 #### List
 
 For example, let's define a variable to be a `list` of `str`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
+
+    Declare the variable, with the same colon (`:`) syntax.
+
+    As the type, put `list`.
+
+    As the list is a type that contains some internal types, you put them in square brackets:
+
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/python_types/tutorial006_py39.py!}
+    ```
+
+=== "Python 3.6+"
 
     From `typing`, import `List` (with a capital `L`):
 
@@ -182,18 +200,6 @@ For example, let's define a variable to be a `list` of `str`.
     {!> ../../../docs_src/python_types/tutorial006.py!}
     ```
 
-=== "Python 3.9 and above"
-
-    Declare the variable, with the same colon (`:`) syntax.
-
-    As the type, put `list`.
-
-    As the list is a type that contains some internal types, you put them in square brackets:
-
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/python_types/tutorial006_py39.py!}
-    ```
-
 !!! info
     Those internal types in the square brackets are called "type parameters".
 
@@ -218,16 +224,16 @@ And still, the editor knows it is a `str`, and provides support for that.
 
 You would do the same to declare `tuple`s and `set`s:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial007.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/python_types/tutorial007_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/python_types/tutorial007_py39.py!}
+    ```Python hl_lines="1  4"
+    {!> ../../../docs_src/python_types/tutorial007.py!}
     ```
 
 This means:
@@ -243,16 +249,16 @@ The first type parameter is for the keys of the `dict`.
 
 The second type parameter is for the values of the `dict`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial008.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/python_types/tutorial008_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/python_types/tutorial008_py39.py!}
+    ```Python hl_lines="1  4"
+    {!> ../../../docs_src/python_types/tutorial008.py!}
     ```
 
 This means:
@@ -267,18 +273,18 @@ You can declare that a variable can be any of **several types**, for example, an
 
 In Python 3.6 and above (including Python 3.10) you can use the `Union` type from `typing` and put inside the square brackets the possible types to accept.
 
-In Python 3.10 there's also an **alternative syntax** where you can put the possible types separated by a <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>vertical bar (`|`)</abbr>.
+In Python 3.10 there's also a **new syntax** where you can put the possible types separated by a <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>vertical bar (`|`)</abbr>.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial008b.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/python_types/tutorial008b_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/python_types/tutorial008b_py310.py!}
+    ```Python hl_lines="1  4"
+    {!> ../../../docs_src/python_types/tutorial008b.py!}
     ```
 
 In both cases this means that `item` could be an `int` or a `str`.
@@ -299,22 +305,22 @@ Using `Optional[str]` instead of just `str` will let the editor help you detecti
 
 This also means that in Python 3.10, you can use `Something | None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial009.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/python_types/tutorial009_py310.py!}
     ```
 
-=== "Python 3.6 and above - alternative"
+=== "Python 3.6+"
 
     ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial009b.py!}
+    {!> ../../../docs_src/python_types/tutorial009.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+ alternative"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/python_types/tutorial009_py310.py!}
+    ```Python hl_lines="1  4"
+    {!> ../../../docs_src/python_types/tutorial009b.py!}
     ```
 
 #### Using `Union` or `Optional`
@@ -360,17 +366,7 @@ And then you won't have to worry about names like `Optional` and `Union`. 😎
 
 These types that take type parameters in square brackets are called **Generic types** or **Generics**, for example:
 
-=== "Python 3.6 and above"
-
-    * `List`
-    * `Tuple`
-    * `Set`
-    * `Dict`
-    * `Union`
-    * `Optional`
-    * ...and others.
-
-=== "Python 3.9 and above"
+=== "Python 3.10+"
 
     You can use the same builtin types as generics (with square brackets and types inside):
 
@@ -382,10 +378,12 @@ These types that take type parameters in square brackets are called **Generic ty
     And the same as with Python 3.6, from the `typing` module:
 
     * `Union`
-    * `Optional`
+    * `Optional` (the same as with Python 3.6)
     * ...and others.
 
-=== "Python 3.10 and above"
+    In Python 3.10, as an alternative to using the generics `Union` and `Optional`, you can use the <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>vertical bar (`|`)</abbr> to declare unions of types, that's a lot better and simpler.
+
+=== "Python 3.9+"
 
     You can use the same builtin types as generics (with square brackets and types inside):
 
@@ -397,10 +395,18 @@ These types that take type parameters in square brackets are called **Generic ty
     And the same as with Python 3.6, from the `typing` module:
 
     * `Union`
-    * `Optional` (the same as with Python 3.6)
+    * `Optional`
     * ...and others.
 
-    In Python 3.10, as an alternative to using the generics `Union` and `Optional`, you can use the <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>vertical bar (`|`)</abbr> to declare unions of types.
+=== "Python 3.6+"
+
+    * `List`
+    * `Tuple`
+    * `Set`
+    * `Dict`
+    * `Union`
+    * `Optional`
+    * ...and others.
 
 ### Classes as types
 
@@ -440,22 +446,22 @@ And you get all the editor support with that resulting object.
 
 An example from the official Pydantic docs:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    {!> ../../../docs_src/python_types/tutorial011.py!}
+    {!> ../../../docs_src/python_types/tutorial011_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python
     {!> ../../../docs_src/python_types/tutorial011_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/python_types/tutorial011_py310.py!}
+    {!> ../../../docs_src/python_types/tutorial011.py!}
     ```
 
 !!! info
@@ -472,22 +478,22 @@ You will see a lot more of all this in practice in the [Tutorial - User Guide](t
 
 Python also has a feature that allows putting **additional metadata** in these type hints using `Annotated`.
 
-=== "Python 3.7 and above"
+=== "Python 3.9+"
 
-    In versions below Python 3.9, you import `Annotated` from `typing_extensions`.
-
-    It will already be installed with **FastAPI**.
+    In Python 3.9, `Annotated` is part of the standard library, so you can import it from `typing`.
 
     ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial013.py!}
+    {!> ../../../docs_src/python_types/tutorial013_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    In Python 3.9, `Annotated` is part of the standard library, so you can import it from `typing`.
+    In versions below Python 3.9, you import `Annotated` from `typing_extensions`.
+
+    It will already be installed with **FastAPI**.
 
     ```Python hl_lines="1  4"
-    {!> ../../../docs_src/python_types/tutorial013_py39.py!}
+    {!> ../../../docs_src/python_types/tutorial013.py!}
     ```
 
 Python itself doesn't do anything with this `Annotated`. And for editors and other tools, the type is still `str`.
index 909e2a72b9379d053dabf5978c52365c64ab1183..582a7e09817a6ed88b85b450f344531520c4d88b 100644 (file)
@@ -57,40 +57,40 @@ Using `BackgroundTasks` also works with the dependency injection system, you can
 
 **FastAPI** knows what to do in each case and how to re-use the same object, so that all the background tasks are merged together and are run in the background afterwards:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="14  16  23  26"
-    {!> ../../../docs_src/background_tasks/tutorial002_an.py!}
+    ```Python hl_lines="13  15  22  25"
+    {!> ../../../docs_src/background_tasks/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="13  15  22  25"
     {!> ../../../docs_src/background_tasks/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13  15  22  25"
-    {!> ../../../docs_src/background_tasks/tutorial002_an_py310.py!}
+    ```Python hl_lines="14  16  23  26"
+    {!> ../../../docs_src/background_tasks/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="13  15  22  25"
-    {!> ../../../docs_src/background_tasks/tutorial002.py!}
+    ```Python hl_lines="11  13  20  23"
+    {!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11  13  20  23"
-    {!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
+    ```Python hl_lines="13  15  22  25"
+    {!> ../../../docs_src/background_tasks/tutorial002.py!}
     ```
 
 In this example, the messages will be written to the `log.txt` file *after* the response is sent.
index 9aeafe29e20bd119d2842e5e2f9d06a1d667224c..b8e3e58072889b563da671501188911fb07c8e81 100644 (file)
@@ -112,19 +112,19 @@ So we put them in their own `dependencies` module (`app/dependencies.py`).
 
 We will now use a simple dependency to read a custom `X-Token` header:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1  5-7"
-    {!> ../../../docs_src/bigger_applications/app_an/dependencies.py!}
+    ```Python hl_lines="3  6-8"
+    {!> ../../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="3  6-8"
-    {!> ../../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
+    ```Python hl_lines="1  5-7"
+    {!> ../../../docs_src/bigger_applications/app_an/dependencies.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 301ee84f2047835cbc20da14ff29b14d45f2bc8e..484d694ea17c95c76106d7aab8a1223a9755f506 100644 (file)
@@ -6,40 +6,40 @@ The same way you can declare additional validation and metadata in *path operati
 
 First, you have to import it:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="4"
-    {!> ../../../docs_src/body_fields/tutorial001_an.py!}
+    {!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="4"
     {!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="4"
-    {!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
+    {!> ../../../docs_src/body_fields/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="4"
-    {!> ../../../docs_src/body_fields/tutorial001.py!}
+    ```Python hl_lines="2"
+    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="2"
-    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
+    ```Python hl_lines="4"
+    {!> ../../../docs_src/body_fields/tutorial001.py!}
     ```
 
 !!! warning
@@ -49,40 +49,40 @@ First, you have to import it:
 
 You can then use `Field` with model attributes:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="12-15"
-    {!> ../../../docs_src/body_fields/tutorial001_an.py!}
+    ```Python hl_lines="11-14"
+    {!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11-14"
     {!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11-14"
-    {!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
+    ```Python hl_lines="12-15"
+    {!> ../../../docs_src/body_fields/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11-14"
-    {!> ../../../docs_src/body_fields/tutorial001.py!}
+    ```Python hl_lines="9-12"
+    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9-12"
-    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
+    ```Python hl_lines="11-14"
+    {!> ../../../docs_src/body_fields/tutorial001.py!}
     ```
 
 `Field` works the same way as `Query`, `Path` and `Body`, it has all the same parameters, etc.
index 1a6b572dcb9ec5693f7e4bbe29ae5d44f8386eaf..3358c6772ca6bacadc084463158bc3619faa6215 100644 (file)
@@ -8,40 +8,40 @@ First, of course, you can mix `Path`, `Query` and request body parameter declara
 
 And you can also declare body parameters as optional, by setting the default to `None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19-21"
-    {!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
+    ```Python hl_lines="18-20"
+    {!> ../../../docs_src/body_multiple_params/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="18-20"
     {!> ../../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18-20"
-    {!> ../../../docs_src/body_multiple_params/tutorial001_an_py310.py!}
+    ```Python hl_lines="19-21"
+    {!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19-21"
-    {!> ../../../docs_src/body_multiple_params/tutorial001.py!}
+    ```Python hl_lines="17-19"
+    {!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17-19"
-    {!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
+    ```Python hl_lines="19-21"
+    {!> ../../../docs_src/body_multiple_params/tutorial001.py!}
     ```
 
 !!! note
@@ -62,16 +62,16 @@ In the previous example, the *path operations* would expect a JSON body with the
 
 But you can also declare multiple body parameters, e.g. `item` and `user`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/body_multiple_params/tutorial002.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/body_multiple_params/tutorial002.py!}
     ```
 
 In this case, **FastAPI** will notice that there are more than one body parameters in the function (two parameters that are Pydantic models).
@@ -111,40 +111,40 @@ If you declare it as is, because it is a singular value, **FastAPI** will assume
 
 But you can instruct **FastAPI** to treat it as another body key using `Body`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="24"
-    {!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
+    ```Python hl_lines="23"
+    {!> ../../../docs_src/body_multiple_params/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="23"
     {!> ../../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="23"
-    {!> ../../../docs_src/body_multiple_params/tutorial003_an_py310.py!}
+    ```Python hl_lines="24"
+    {!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/body_multiple_params/tutorial003.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/body_multiple_params/tutorial003.py!}
     ```
 
 In this case, **FastAPI** will expect a body like:
@@ -185,40 +185,40 @@ q: str | None = None
 
 For example:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="28"
-    {!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
+    ```Python hl_lines="27"
+    {!> ../../../docs_src/body_multiple_params/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="27"
     {!> ../../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="27"
-    {!> ../../../docs_src/body_multiple_params/tutorial004_an_py310.py!}
+    ```Python hl_lines="28"
+    {!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="27"
-    {!> ../../../docs_src/body_multiple_params/tutorial004.py!}
+    ```Python hl_lines="25"
+    {!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="25"
-    {!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
+    ```Python hl_lines="27"
+    {!> ../../../docs_src/body_multiple_params/tutorial004.py!}
     ```
 
 !!! info
@@ -238,40 +238,40 @@ item: Item = Body(embed=True)
 
 as in:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/body_multiple_params/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="17"
     {!> ../../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/body_multiple_params/tutorial005_an_py310.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/body_multiple_params/tutorial005.py!}
+    ```Python hl_lines="15"
+    {!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="15"
-    {!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/body_multiple_params/tutorial005.py!}
     ```
 
 In this case **FastAPI** will expect a body like:
index d51f171d6e2f4186cbbbc69a37469572043f802f..ffa0c0d0ef74fb7e8a39df75a2a7af88c8250f82 100644 (file)
@@ -6,16 +6,16 @@ With **FastAPI**, you can define, validate, document, and use arbitrarily deeply
 
 You can define an attribute to be a subtype. For example, a Python `list`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="14"
-    {!> ../../../docs_src/body_nested_models/tutorial001.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
+    ```Python hl_lines="14"
+    {!> ../../../docs_src/body_nested_models/tutorial001.py!}
     ```
 
 This will make `tags` be a list, although it doesn't declare the type of the elements of the list.
@@ -61,22 +61,22 @@ Use that same standard syntax for model attributes with internal types.
 
 So, in our example, we can make `tags` be specifically a "list of strings":
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="14"
-    {!> ../../../docs_src/body_nested_models/tutorial002.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/body_nested_models/tutorial002_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="14"
     {!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/body_nested_models/tutorial002_py310.py!}
+    ```Python hl_lines="14"
+    {!> ../../../docs_src/body_nested_models/tutorial002.py!}
     ```
 
 ## Set types
@@ -87,22 +87,22 @@ And Python has a special data type for sets of unique items, the `set`.
 
 Then we can declare `tags` as a set of strings:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="1  14"
-    {!> ../../../docs_src/body_nested_models/tutorial003.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/body_nested_models/tutorial003_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="14"
     {!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/body_nested_models/tutorial003_py310.py!}
+    ```Python hl_lines="1  14"
+    {!> ../../../docs_src/body_nested_models/tutorial003.py!}
     ```
 
 With this, even if you receive a request with duplicate data, it will be converted to a set of unique items.
@@ -125,44 +125,44 @@ All that, arbitrarily nested.
 
 For example, we can define an `Image` model:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9-11"
-    {!> ../../../docs_src/body_nested_models/tutorial004.py!}
+    ```Python hl_lines="7-9"
+    {!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9-11"
     {!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7-9"
-    {!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
+    ```Python hl_lines="9-11"
+    {!> ../../../docs_src/body_nested_models/tutorial004.py!}
     ```
 
 ### Use the submodel as a type
 
 And then we can use it as the type of an attribute:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/body_nested_models/tutorial004.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="20"
     {!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/body_nested_models/tutorial004.py!}
     ```
 
 This would mean that **FastAPI** would expect a body similar to:
@@ -196,22 +196,22 @@ To see all the options you have, checkout the docs for <a href="https://pydantic
 
 For example, as in the `Image` model we have a `url` field, we can declare it to be instead of a `str`, a Pydantic's `HttpUrl`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4  10"
-    {!> ../../../docs_src/body_nested_models/tutorial005.py!}
+    ```Python hl_lines="2  8"
+    {!> ../../../docs_src/body_nested_models/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="4  10"
     {!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="2  8"
-    {!> ../../../docs_src/body_nested_models/tutorial005_py310.py!}
+    ```Python hl_lines="4  10"
+    {!> ../../../docs_src/body_nested_models/tutorial005.py!}
     ```
 
 The string will be checked to be a valid URL, and documented in JSON Schema / OpenAPI as such.
@@ -220,22 +220,22 @@ The string will be checked to be a valid URL, and documented in JSON Schema / Op
 
 You can also use Pydantic models as subtypes of `list`, `set`, etc:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/body_nested_models/tutorial006.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/body_nested_models/tutorial006_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="20"
     {!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/body_nested_models/tutorial006_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/body_nested_models/tutorial006.py!}
     ```
 
 This will expect (convert, validate, document, etc) a JSON body like:
@@ -271,22 +271,22 @@ This will expect (convert, validate, document, etc) a JSON body like:
 
 You can define arbitrarily deeply nested models:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9  14  20  23  27"
-    {!> ../../../docs_src/body_nested_models/tutorial007.py!}
+    ```Python hl_lines="7  12  18  21  25"
+    {!> ../../../docs_src/body_nested_models/tutorial007_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9  14  20  23  27"
     {!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  12  18  21  25"
-    {!> ../../../docs_src/body_nested_models/tutorial007_py310.py!}
+    ```Python hl_lines="9  14  20  23  27"
+    {!> ../../../docs_src/body_nested_models/tutorial007.py!}
     ```
 
 !!! info
@@ -308,16 +308,16 @@ images: list[Image]
 
 as in:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="15"
-    {!> ../../../docs_src/body_nested_models/tutorial008.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
+    ```Python hl_lines="15"
+    {!> ../../../docs_src/body_nested_models/tutorial008.py!}
     ```
 
 ## Editor support everywhere
@@ -348,16 +348,16 @@ That's what we are going to see here.
 
 In this case, you would accept any `dict` as long as it has `int` keys with `float` values:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/body_nested_models/tutorial009.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/body_nested_models/tutorial009.py!}
     ```
 
 !!! tip
index 7d8675060f3f8daa2026011bde1898b0b1727c1b..a32948db1a104bb6dffb86ce4a888291b6484ed9 100644 (file)
@@ -6,22 +6,22 @@ To update an item you can use the <a href="https://developer.mozilla.org/en-US/d
 
 You can use the `jsonable_encoder` to convert the input data to data that can be stored as JSON (e.g. with a NoSQL database). For example, converting `datetime` to `str`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="30-35"
-    {!> ../../../docs_src/body_updates/tutorial001.py!}
+    ```Python hl_lines="28-33"
+    {!> ../../../docs_src/body_updates/tutorial001_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="30-35"
     {!> ../../../docs_src/body_updates/tutorial001_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="28-33"
-    {!> ../../../docs_src/body_updates/tutorial001_py310.py!}
+    ```Python hl_lines="30-35"
+    {!> ../../../docs_src/body_updates/tutorial001.py!}
     ```
 
 `PUT` is used to receive data that should replace the existing data.
@@ -67,22 +67,22 @@ That would generate a `dict` with only the data that was set when creating the `
 
 Then you can use this to generate a `dict` with only the data that was set (sent in the request), omitting default values:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="34"
-    {!> ../../../docs_src/body_updates/tutorial002.py!}
+    ```Python hl_lines="32"
+    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="34"
     {!> ../../../docs_src/body_updates/tutorial002_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="32"
-    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
+    ```Python hl_lines="34"
+    {!> ../../../docs_src/body_updates/tutorial002.py!}
     ```
 
 ### Using Pydantic's `update` parameter
@@ -91,22 +91,22 @@ Now, you can create a copy of the existing model using `.copy()`, and pass the `
 
 Like `stored_item_model.copy(update=update_data)`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="35"
-    {!> ../../../docs_src/body_updates/tutorial002.py!}
+    ```Python hl_lines="33"
+    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="35"
     {!> ../../../docs_src/body_updates/tutorial002_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="33"
-    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
+    ```Python hl_lines="35"
+    {!> ../../../docs_src/body_updates/tutorial002.py!}
     ```
 
 ### Partial updates recap
@@ -124,22 +124,22 @@ In summary, to apply partial updates you would:
 * Save the data to your DB.
 * Return the updated model.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="30-37"
-    {!> ../../../docs_src/body_updates/tutorial002.py!}
+    ```Python hl_lines="28-35"
+    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="30-37"
     {!> ../../../docs_src/body_updates/tutorial002_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="28-35"
-    {!> ../../../docs_src/body_updates/tutorial002_py310.py!}
+    ```Python hl_lines="30-37"
+    {!> ../../../docs_src/body_updates/tutorial002.py!}
     ```
 
 !!! tip
index 5090059360ba75a50832f1dd83dbee7aa33ba13b..172b91fdfa61e30eb081ab20225b9cafdcf03a73 100644 (file)
@@ -19,16 +19,16 @@ To declare a **request** body, you use <a href="https://pydantic-docs.helpmanual
 
 First, you need to import `BaseModel` from `pydantic`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4"
-    {!> ../../../docs_src/body/tutorial001.py!}
+    ```Python hl_lines="2"
+    {!> ../../../docs_src/body/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="2"
-    {!> ../../../docs_src/body/tutorial001_py310.py!}
+    ```Python hl_lines="4"
+    {!> ../../../docs_src/body/tutorial001.py!}
     ```
 
 ## Create your data model
@@ -37,16 +37,16 @@ Then you declare your data model as a class that inherits from `BaseModel`.
 
 Use standard Python types for all the attributes:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="7-11"
-    {!> ../../../docs_src/body/tutorial001.py!}
+    ```Python hl_lines="5-9"
+    {!> ../../../docs_src/body/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="5-9"
-    {!> ../../../docs_src/body/tutorial001_py310.py!}
+    ```Python hl_lines="7-11"
+    {!> ../../../docs_src/body/tutorial001.py!}
     ```
 
 The same as when declaring query parameters, when a model attribute has a default value, it is not required. Otherwise, it is required. Use `None` to make it just optional.
@@ -75,16 +75,16 @@ For example, this model above declares a JSON "`object`" (or Python `dict`) like
 
 To add it to your *path operation*, declare it the same way you declared path and query parameters:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/body/tutorial001.py!}
+    ```Python hl_lines="16"
+    {!> ../../../docs_src/body/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="16"
-    {!> ../../../docs_src/body/tutorial001_py310.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/body/tutorial001.py!}
     ```
 
 ...and declare its type as the model you created, `Item`.
@@ -149,16 +149,16 @@ But you would get the same editor support with <a href="https://www.jetbrains.co
 
 Inside of the function, you can access all the attributes of the model object directly:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="21"
-    {!> ../../../docs_src/body/tutorial002.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/body/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/body/tutorial002_py310.py!}
+    ```Python hl_lines="21"
+    {!> ../../../docs_src/body/tutorial002.py!}
     ```
 
 ## Request body + path parameters
@@ -167,16 +167,16 @@ You can declare path parameters and request body at the same time.
 
 **FastAPI** will recognize that the function parameters that match path parameters should be **taken from the path**, and that function parameters that are declared to be Pydantic models should be **taken from the request body**.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="17-18"
-    {!> ../../../docs_src/body/tutorial003.py!}
+    ```Python hl_lines="15-16"
+    {!> ../../../docs_src/body/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="15-16"
-    {!> ../../../docs_src/body/tutorial003_py310.py!}
+    ```Python hl_lines="17-18"
+    {!> ../../../docs_src/body/tutorial003.py!}
     ```
 
 ## Request body + path + query parameters
@@ -185,16 +185,16 @@ You can also declare **body**, **path** and **query** parameters, all at the sam
 
 **FastAPI** will recognize each of them and take the data from the correct place.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/body/tutorial004.py!}
+    ```Python hl_lines="16"
+    {!> ../../../docs_src/body/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="16"
-    {!> ../../../docs_src/body/tutorial004_py310.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/body/tutorial004.py!}
     ```
 
 The function parameters will be recognized as follows:
index 2aab8d12df1bdc601df2641a36b383f7381ead65..169c546f0a66b096cb2727a53a9714f0ee5c23b4 100644 (file)
@@ -6,40 +6,40 @@ You can define Cookie parameters the same way you define `Query` and `Path` para
 
 First import `Cookie`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/cookie_params/tutorial001_an.py!}
+    {!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3"
     {!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
+    {!> ../../../docs_src/cookie_params/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/cookie_params/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/cookie_params/tutorial001.py!}
     ```
 
 ## Declare `Cookie` parameters
@@ -48,40 +48,40 @@ Then declare the cookie parameters using the same structure as with `Path` and `
 
 The first value is the default value, you can pass all the extra validation or annotation parameters:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/cookie_params/tutorial001_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/cookie_params/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/cookie_params/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/cookie_params/tutorial001.py!}
     ```
 
 !!! note "Technical Details"
index 4fa05c98e5ba05b21e36bb940415aa5352809d1e..832e23997ce51b29eb071b5054528d653d2bc876 100644 (file)
@@ -6,40 +6,40 @@ Before diving deeper into the **Dependency Injection** system, let's upgrade the
 
 In the previous example, we were returning a `dict` from our dependency ("dependable"):
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11"
     {!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 But then we get a `dict` in the parameter `commons` of the *path operation function*.
@@ -103,116 +103,116 @@ That also applies to callables with no parameters at all. The same as it would b
 
 Then, we can change the dependency "dependable" `common_parameters` from above to the class `CommonQueryParams`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="12-16"
-    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
+    ```Python hl_lines="11-15"
+    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11-15"
     {!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11-15"
-    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
+    ```Python hl_lines="12-16"
+    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11-15"
-    {!> ../../../docs_src/dependencies/tutorial002.py!}
+    ```Python hl_lines="9-13"
+    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9-13"
-    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
+    ```Python hl_lines="11-15"
+    {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
 Pay attention to the `__init__` method used to create the instance of the class:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="12"
     {!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/dependencies/tutorial002.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
 ...it has the same parameters as our previous `common_parameters`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="6"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="6"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 Those parameters are what **FastAPI** will use to "solve" the dependency.
@@ -229,41 +229,40 @@ In both cases the data will be converted, validated, documented on the OpenAPI s
 
 Now you can declare your dependency using this class.
 
+=== "Python 3.10+"
 
-=== "Python 3.6 and above"
-
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19"
     {!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/dependencies/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial002.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
 **FastAPI** calls the `CommonQueryParams` class. This creates an "instance" of that class and the instance will be passed as the parameter `commons` to your function.
@@ -272,13 +271,7 @@ Now you can declare your dependency using this class.
 
 Notice how we write `CommonQueryParams` twice in the above code:
 
-=== "Python 3.6 and above"
-
-    ```Python
-    commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
-    ```
-
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -287,6 +280,12 @@ Notice how we write `CommonQueryParams` twice in the above code:
     commons: CommonQueryParams = Depends(CommonQueryParams)
     ```
 
+=== "Python 3.6+"
+
+    ```Python
+    commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
+    ```
+
 The last `CommonQueryParams`, in:
 
 ```Python
@@ -301,13 +300,13 @@ From it is that FastAPI will extract the declared parameters and that is what Fa
 
 In this case, the first `CommonQueryParams`, in:
 
-=== "Python 3.6 and above"
+=== "Python 3.6+"
 
     ```Python
     commons: Annotated[CommonQueryParams, ...
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -320,13 +319,13 @@ In this case, the first `CommonQueryParams`, in:
 
 You could actually write just:
 
-=== "Python 3.6 and above"
+=== "Python 3.6+"
 
     ```Python
     commons: Annotated[Any, Depends(CommonQueryParams)]
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -337,40 +336,40 @@ You could actually write just:
 
 ..as in:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/dependencies/tutorial003_an.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19"
     {!> ../../../docs_src/dependencies/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial003_an_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/dependencies/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial003.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial003_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial003.py!}
     ```
 
 But declaring the type is encouraged as that way your editor will know what will be passed as the parameter `commons`, and then it can help you with code completion, type checks, etc:
@@ -381,13 +380,7 @@ But declaring the type is encouraged as that way your editor will know what will
 
 But you see that we are having some code repetition here, writing `CommonQueryParams` twice:
 
-=== "Python 3.6 and above"
-
-    ```Python
-    commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
-    ```
-
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -396,19 +389,25 @@ But you see that we are having some code repetition here, writing `CommonQueryPa
     commons: CommonQueryParams = Depends(CommonQueryParams)
     ```
 
+=== "Python 3.6+"
+
+    ```Python
+    commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
+    ```
+
 **FastAPI** provides a shortcut for these cases, in where the dependency is *specifically* a class that **FastAPI** will "call" to create an instance of the class itself.
 
 For those specific cases, you can do the following:
 
 Instead of writing:
 
-=== "Python 3.6 and above"
+=== "Python 3.6+"
 
     ```Python
     commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -419,13 +418,13 @@ Instead of writing:
 
 ...you write:
 
-=== "Python 3.6 and above"
+=== "Python 3.6+"
 
     ```Python
     commons: Annotated[CommonQueryParams, Depends()]
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -438,40 +437,40 @@ You declare the dependency as the type of the parameter, and you use `Depends()`
 
 The same example would then look like:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/dependencies/tutorial004_an.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19"
     {!> ../../../docs_src/dependencies/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial004_an_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/dependencies/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial004.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial004_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial004.py!}
     ```
 
 ...and **FastAPI** will know what to do.
index d3a11c1494bcc8754dad12b2958ff924d01658dc..aef9bf5e16866bf5a6cf430dea26e6a875eea995 100644 (file)
@@ -14,19 +14,19 @@ The *path operation decorator* receives an optional argument `dependencies`.
 
 It should be a `list` of `Depends()`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -57,19 +57,19 @@ You can use the same dependency *functions* you use normally.
 
 They can declare request requirements (like headers) or other sub-dependencies:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="7  12"
-    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
+    ```Python hl_lines="8  13"
+    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8  13"
-    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
+    ```Python hl_lines="7  12"
+    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -82,19 +82,19 @@ They can declare request requirements (like headers) or other sub-dependencies:
 
 These dependencies can `raise` exceptions, the same as normal dependencies:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9  14"
-    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
+    ```Python hl_lines="10  15"
+    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10  15"
-    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
+    ```Python hl_lines="9  14"
+    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -109,19 +109,19 @@ And they can return values or not, the values won't be used.
 
 So, you can re-use a normal dependency (that returns a value) you already use somewhere else, and even though the value won't be used, the dependency will be executed:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="10  15"
-    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
+    ```Python hl_lines="11  16"
+    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11  16"
-    {!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
+    ```Python hl_lines="10  15"
+    {!> ../../../docs_src/dependencies/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index d0c263f40d743617dfbc203b047c111188541b9e..721fee162d4eb66e77dd91be9b40058499244c74 100644 (file)
@@ -66,19 +66,19 @@ You can have sub-dependencies and "trees" of sub-dependencies of any size and sh
 
 For example, `dependency_c` can have a dependency on `dependency_b`, and `dependency_b` on `dependency_a`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="5  13  21"
-    {!> ../../../docs_src/dependencies/tutorial008_an.py!}
+    ```Python hl_lines="6  14  22"
+    {!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6  14  22"
-    {!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
+    ```Python hl_lines="5  13  21"
+    {!> ../../../docs_src/dependencies/tutorial008_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -93,19 +93,19 @@ In this case `dependency_c`, to execute its exit code, needs the value from `dep
 
 And, in turn, `dependency_b` needs the value from `dependency_a` (here named `dep_a`) to be available for its exit code.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="17-18  25-26"
-    {!> ../../../docs_src/dependencies/tutorial008_an.py!}
+    ```Python hl_lines="18-19  26-27"
+    {!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18-19  26-27"
-    {!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
+    ```Python hl_lines="17-18  25-26"
+    {!> ../../../docs_src/dependencies/tutorial008_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 9ad503d8f5b65af1e97ee9d4ca34b6f86afbe675..f148388ee6519b282406688d021ed059976256c1 100644 (file)
@@ -6,20 +6,19 @@ Similar to the way you can [add `dependencies` to the *path operation decorators
 
 In that case, they will be applied to all the *path operations* in the application:
 
-
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="16"
-    {!> ../../../docs_src/dependencies/tutorial012_an.py!}
+    {!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="16"
-    {!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
+    {!> ../../../docs_src/dependencies/tutorial012_an.py!}
     ```
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 5675b8dfd504fe37f055daf436f50562e4008e63..7ae32f8b873709e552289623eb2ce84e3d32c892 100644 (file)
@@ -31,40 +31,40 @@ Let's first focus on the dependency.
 
 It is just a function that can take all the same parameters that a *path operation function* can take:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9-12"
-    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
+    ```Python hl_lines="8-9"
+    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="8-11"
     {!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8-9"
-    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
+    ```Python hl_lines="9-12"
+    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8-11"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="6-7"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="6-7"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="8-11"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 That's it.
@@ -87,80 +87,80 @@ And then it just returns a `dict` containing those values.
 
 ### Import `Depends`
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
+    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3"
     {!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
+    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 ### Declare the dependency, in the "dependant"
 
 The same way you use `Body`, `Query`, etc. with your *path operation function* parameters, use `Depends` with a new parameter:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="16  21"
-    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
+    ```Python hl_lines="13  18"
+    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="15  20"
     {!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13  18"
-    {!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
+    ```Python hl_lines="16  21"
+    {!> ../../../docs_src/dependencies/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="15  20"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="11  16"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11  16"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="15  20"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 Although you use `Depends` in the parameters of your function the same way you use `Body`, `Query`, etc, `Depends` works a bit differently.
@@ -212,22 +212,22 @@ commons: Annotated[dict, Depends(common_parameters)]
 
 But because we are using `Annotated`, we can store that `Annotated` value in a variable and use it in multiple places:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15  19  24"
-    {!> ../../../docs_src/dependencies/tutorial001_02_an.py!}
+    ```Python hl_lines="12  16  21"
+    {!> ../../../docs_src/dependencies/tutorial001_02_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="14  18  23"
     {!> ../../../docs_src/dependencies/tutorial001_02_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12  16  21"
-    {!> ../../../docs_src/dependencies/tutorial001_02_an_py310.py!}
+    ```Python hl_lines="15  19  24"
+    {!> ../../../docs_src/dependencies/tutorial001_02_an.py!}
     ```
 
 !!! tip
index 8b70e260277f07c54c8536c7fb9b48998c515971..27af5970d5c73fc470306dea9f3896df7ea7c524 100644 (file)
@@ -10,40 +10,40 @@ They can be as **deep** as you need them to be.
 
 You could create a first dependency ("dependable") like:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9-10"
-    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
+    ```Python hl_lines="8-9"
+    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="8-9"
     {!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8-9"
-    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
+    ```Python hl_lines="9-10"
+    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 - non-Annotated"
+=== "Python 3.10 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8-9"
-    {!> ../../../docs_src/dependencies/tutorial005.py!}
+    ```Python hl_lines="6-7"
+    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 - non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="6-7"
-    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
+    ```Python hl_lines="8-9"
+    {!> ../../../docs_src/dependencies/tutorial005.py!}
     ```
 
 It declares an optional query parameter `q` as a `str`, and then it just returns it.
@@ -54,40 +54,40 @@ This is quite simple (not very useful), but will help us focus on how the sub-de
 
 Then you can create another dependency function (a "dependable") that at the same time declares a dependency of its own (so it is a "dependant" too):
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="14"
-    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="13"
     {!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
+    ```Python hl_lines="14"
+    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 - non-Annotated"
+=== "Python 3.10 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/dependencies/tutorial005.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 - non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/dependencies/tutorial005.py!}
     ```
 
 Let's focus on the parameters declared:
@@ -101,40 +101,40 @@ Let's focus on the parameters declared:
 
 Then we can use the dependency with:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="24"
-    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
+    ```Python hl_lines="23"
+    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="23"
     {!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="23"
-    {!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
+    ```Python hl_lines="24"
+    {!> ../../../docs_src/dependencies/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 - non-Annotated"
+=== "Python 3.10 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/dependencies/tutorial005.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 - non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial005_py310.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/dependencies/tutorial005.py!}
     ```
 
 !!! info
@@ -161,14 +161,14 @@ And it will save the returned value in a <abbr title="A utility/system to store
 
 In an advanced scenario where you know you need the dependency to be called at every step (possibly multiple times) in the same request instead of using the "cached" value, you can set the parameter `use_cache=False` when using `Depends`:
 
-=== "Python 3.6 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="1"
     async def needy_dependency(fresh_value: Annotated[str, Depends(get_value, use_cache=False)]):
         return {"fresh_value": fresh_value}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 7a69c5474a31842bc9a4d5d1e76e21151baa7ec3..735aa2209ffedf0148b3b0d7b26e75ad2efc1df7 100644 (file)
@@ -20,16 +20,16 @@ You can use `jsonable_encoder` for that.
 
 It receives an object, like a Pydantic model, and returns a JSON compatible version:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="5  22"
-    {!> ../../../docs_src/encoder/tutorial001.py!}
+    ```Python hl_lines="4  21"
+    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  21"
-    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
+    ```Python hl_lines="5  22"
+    {!> ../../../docs_src/encoder/tutorial001.py!}
     ```
 
 In this example, it would convert the Pydantic model to a `dict`, and the `datetime` to a `str`.
index 440f00d18093e7fcc939790ed474fd2b1e55f018..0d969b41dfdf1d6606fc2d9483e619837753f3ac 100644 (file)
@@ -55,76 +55,76 @@ Here are some of the additional data types you can use:
 
 Here's an example *path operation* with parameters using some of the above types.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="1  3  13-17"
-    {!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
+    ```Python hl_lines="1  3  12-16"
+    {!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="1  3  12-16"
     {!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1  3  12-16"
-    {!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
+    ```Python hl_lines="1  3  13-17"
+    {!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1  2  12-16"
-    {!> ../../../docs_src/extra_data_types/tutorial001.py!}
+    ```Python hl_lines="1  2  11-15"
+    {!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1  2  11-15"
-    {!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
+    ```Python hl_lines="1  2  12-16"
+    {!> ../../../docs_src/extra_data_types/tutorial001.py!}
     ```
 
 Note that the parameters inside the function have their natural data type, and you can, for example, perform normal date manipulations, like:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19-20"
-    {!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
+    ```Python hl_lines="18-19"
+    {!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="18-19"
     {!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18-19"
-    {!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
+    ```Python hl_lines="19-20"
+    {!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="18-19"
-    {!> ../../../docs_src/extra_data_types/tutorial001.py!}
+    ```Python hl_lines="17-18"
+    {!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17-18"
-    {!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
+    ```Python hl_lines="18-19"
+    {!> ../../../docs_src/extra_data_types/tutorial001.py!}
     ```
index 72fc74894ceb1eba6bc76e44105118ce85b59a16..e91e879e41672a1340057f09fb880916bc358bc5 100644 (file)
@@ -17,16 +17,16 @@ This is especially the case for user models, because:
 
 Here's a general idea of how the models could look like with their password fields and the places where they are used:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9  11  16  22  24  29-30  33-35  40-41"
-    {!> ../../../docs_src/extra_models/tutorial001.py!}
+    ```Python hl_lines="7  9  14  20  22  27-28  31-33  38-39"
+    {!> ../../../docs_src/extra_models/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  9  14  20  22  27-28  31-33  38-39"
-    {!> ../../../docs_src/extra_models/tutorial001_py310.py!}
+    ```Python hl_lines="9  11  16  22  24  29-30  33-35  40-41"
+    {!> ../../../docs_src/extra_models/tutorial001.py!}
     ```
 
 ### About `**user_in.dict()`
@@ -158,16 +158,16 @@ All the data conversion, validation, documentation, etc. will still work as norm
 
 That way, we can declare just the differences between the models (with plaintext `password`, with `hashed_password` and without password):
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9  15-16  19-20  23-24"
-    {!> ../../../docs_src/extra_models/tutorial002.py!}
+    ```Python hl_lines="7  13-14  17-18  21-22"
+    {!> ../../../docs_src/extra_models/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  13-14  17-18  21-22"
-    {!> ../../../docs_src/extra_models/tutorial002_py310.py!}
+    ```Python hl_lines="9  15-16  19-20  23-24"
+    {!> ../../../docs_src/extra_models/tutorial002.py!}
     ```
 
 ## `Union` or `anyOf`
@@ -181,16 +181,16 @@ To do that, use the standard Python type hint <a href="https://docs.python.org/3
 !!! note
     When defining a <a href="https://pydantic-docs.helpmanual.io/usage/types/#unions" class="external-link" target="_blank">`Union`</a>, include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="1  14-15  18-20  33"
-    {!> ../../../docs_src/extra_models/tutorial003.py!}
+    {!> ../../../docs_src/extra_models/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="1  14-15  18-20  33"
-    {!> ../../../docs_src/extra_models/tutorial003_py310.py!}
+    {!> ../../../docs_src/extra_models/tutorial003.py!}
     ```
 
 ### `Union` in Python 3.10
@@ -213,16 +213,16 @@ The same way, you can declare responses of lists of objects.
 
 For that, use the standard Python `typing.List` (or just `list` in Python 3.9 and above):
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1  20"
-    {!> ../../../docs_src/extra_models/tutorial004.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/extra_models/tutorial004_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/extra_models/tutorial004_py39.py!}
+    ```Python hl_lines="1  20"
+    {!> ../../../docs_src/extra_models/tutorial004.py!}
     ```
 
 ## Response with arbitrary `dict`
@@ -233,16 +233,16 @@ This is useful if you don't know the valid field/attribute names (that would be
 
 In this case, you can use `typing.Dict` (or just `dict` in Python 3.9 and above):
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1  8"
-    {!> ../../../docs_src/extra_models/tutorial005.py!}
+    ```Python hl_lines="6"
+    {!> ../../../docs_src/extra_models/tutorial005_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6"
-    {!> ../../../docs_src/extra_models/tutorial005_py39.py!}
+    ```Python hl_lines="1  8"
+    {!> ../../../docs_src/extra_models/tutorial005.py!}
     ```
 
 ## Recap
index 4753591345f15740393a618ec16da031365e7c38..47ebbefcf048d01ec3dac86184b964b4b4fae96a 100644 (file)
@@ -6,40 +6,40 @@ You can define Header parameters the same way you define `Query`, `Path` and `Co
 
 First import `Header`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/header_params/tutorial001_an.py!}
+    {!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3"
     {!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="3"
-    {!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
+    {!> ../../../docs_src/header_params/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/header_params/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/header_params/tutorial001.py!}
     ```
 
 ## Declare `Header` parameters
@@ -48,40 +48,40 @@ Then declare the header parameters using the same structure as with `Path`, `Que
 
 The first value is the default value, you can pass all the extra validation or annotation parameters:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/header_params/tutorial001_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/header_params/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial001.py!}
     ```
 
 !!! note "Technical Details"
@@ -108,40 +108,40 @@ So, you can use `user_agent` as you normally would in Python code, instead of ne
 
 If for some reason you need to disable automatic conversion of underscores to hyphens, set the parameter `convert_underscores` of `Header` to `False`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/header_params/tutorial002_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/header_params/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11"
     {!> ../../../docs_src/header_params/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/header_params/tutorial002_an_py310.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/header_params/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/header_params/tutorial002.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/header_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/header_params/tutorial002_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/header_params/tutorial002.py!}
     ```
 
 !!! warning
@@ -157,34 +157,34 @@ You will receive all the values from the duplicate header as a Python `list`.
 
 For example, to declare a header of `X-Token` that can appear more than once, you can write:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/header_params/tutorial003_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/header_params/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial003_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/header_params/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial003.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/header_params/tutorial003_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -193,13 +193,13 @@ For example, to declare a header of `X-Token` that can appear more than once, yo
     {!> ../../../docs_src/header_params/tutorial003_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/header_params/tutorial003_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial003.py!}
     ```
 
 If you communicate with that *path operation* sending two HTTP headers like:
index 884a762e24a03d3f32330e0a3b67daa71f22a52b..7d4d4bccaf64c111beb1c845661f121dd58a8790 100644 (file)
@@ -13,22 +13,22 @@ You can pass directly the `int` code, like `404`.
 
 But if you don't remember what each number code is for, you can use the shortcut constants in `status`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3  17"
-    {!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
+    ```Python hl_lines="1  15"
+    {!> ../../../docs_src/path_operation_configuration/tutorial001_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3  17"
     {!> ../../../docs_src/path_operation_configuration/tutorial001_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1  15"
-    {!> ../../../docs_src/path_operation_configuration/tutorial001_py310.py!}
+    ```Python hl_lines="3  17"
+    {!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
     ```
 
 That status code will be used in the response and will be added to the OpenAPI schema.
@@ -42,22 +42,22 @@ That status code will be used in the response and will be added to the OpenAPI s
 
 You can add tags to your *path operation*, pass the parameter `tags` with a `list` of `str` (commonly just one `str`):
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="17  22  27"
-    {!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
+    ```Python hl_lines="15  20  25"
+    {!> ../../../docs_src/path_operation_configuration/tutorial002_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="17  22  27"
     {!> ../../../docs_src/path_operation_configuration/tutorial002_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="15  20  25"
-    {!> ../../../docs_src/path_operation_configuration/tutorial002_py310.py!}
+    ```Python hl_lines="17  22  27"
+    {!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
     ```
 
 They will be added to the OpenAPI schema and used by the automatic documentation interfaces:
@@ -80,22 +80,22 @@ In these cases, it could make sense to store the tags in an `Enum`.
 
 You can add a `summary` and `description`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20-21"
-    {!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
+    ```Python hl_lines="18-19"
+    {!> ../../../docs_src/path_operation_configuration/tutorial003_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="20-21"
     {!> ../../../docs_src/path_operation_configuration/tutorial003_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="18-19"
-    {!> ../../../docs_src/path_operation_configuration/tutorial003_py310.py!}
+    ```Python hl_lines="20-21"
+    {!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
     ```
 
 ## Description from docstring
@@ -104,22 +104,22 @@ As descriptions tend to be long and cover multiple lines, you can declare the *p
 
 You can write <a href="https://en.wikipedia.org/wiki/Markdown" class="external-link" target="_blank">Markdown</a> in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation).
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19-27"
-    {!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
+    ```Python hl_lines="17-25"
+    {!> ../../../docs_src/path_operation_configuration/tutorial004_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19-27"
     {!> ../../../docs_src/path_operation_configuration/tutorial004_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17-25"
-    {!> ../../../docs_src/path_operation_configuration/tutorial004_py310.py!}
+    ```Python hl_lines="19-27"
+    {!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
     ```
 
 It will be used in the interactive docs:
@@ -130,22 +130,22 @@ It will be used in the interactive docs:
 
 You can specify the response description with the parameter `response_description`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="21"
-    {!> ../../../docs_src/path_operation_configuration/tutorial005.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/path_operation_configuration/tutorial005_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="21"
     {!> ../../../docs_src/path_operation_configuration/tutorial005_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/path_operation_configuration/tutorial005_py310.py!}
+    ```Python hl_lines="21"
+    {!> ../../../docs_src/path_operation_configuration/tutorial005.py!}
     ```
 
 !!! info
index c6f158307eac89b0efa94752c0e8cfe005e8a0da..c2c12f6e938669458317fcc72728e01443b79374 100644 (file)
@@ -6,40 +6,40 @@ In the same way that you can declare more validations and metadata for query par
 
 First, import `Path` from `fastapi`, and import `Annotated`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3-4"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
+    ```Python hl_lines="1  3"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="1  3"
     {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1  3"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
+    ```Python hl_lines="3-4"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
     ```
 
 ## Declare metadata
@@ -48,40 +48,40 @@ You can declare all the same parameters as for `Query`.
 
 For example, to declare a `title` metadata value for the path parameter `item_id` you can type:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="10"
     {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
     ```
 
 !!! note
@@ -110,7 +110,7 @@ It doesn't matter for **FastAPI**. It will detect the parameters by their names,
 
 So, you can declare your function as:
 
-=== "Python 3.6 non-Annotated"
+=== "Python 3.6 non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -121,16 +121,16 @@ So, you can declare your function as:
 
 But have in mind that if you use `Annotated`, you won't have this problem, it won't matter as you're not using the function parameter default values for `Query()` or `Path()`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
     ```
 
 ## Order the parameters as you need, tricks
@@ -161,16 +161,16 @@ Python won't do anything with that `*`, but it will know that all the following
 
 Have in mind that if you use `Annotated`, as you are not using function parameter default values, you won't have this problem, and yo probably won't need to use `*`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
     ```
 
 ## Number validations: greater than or equal
@@ -179,19 +179,19 @@ With `Query` and `Path` (and others you'll see later) you can declare number con
 
 Here, with `ge=1`, `item_id` will need to be an integer number "`g`reater than or `e`qual" to `1`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -207,19 +207,19 @@ The same applies for:
 * `gt`: `g`reater `t`han
 * `le`: `l`ess than or `e`qual
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -238,19 +238,19 @@ So, `0.5` would be a valid value. But `0.0` or `0` would not.
 
 And the same for <abbr title="less than"><code>lt</code></abbr>.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index a12b0b41a8afaed00dff2c8e2844075b63d259ea..3584ca0b3df283995aafa02d4bb38c773e784fd4 100644 (file)
@@ -4,16 +4,16 @@
 
 Let's take this application as example:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
     ```
 
 The query parameter `q` is of type `Union[str, None]` (or `str | None` in Python 3.10), that means that it's of type `str` but could also be `None`, and indeed, the default value is `None`, so FastAPI will know it's not required.
@@ -34,7 +34,15 @@ To achieve that, first import:
 * `Query` from `fastapi`
 * `Annotated` from `typing` (or from `typing_extensions` in Python below 3.9)
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
+
+    In Python 3.9 or above, `Annotated` is part of the standard library, so you can import it from `typing`.
+
+    ```Python hl_lines="1  3"
+    {!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
+    ```
+
+=== "Python 3.6+"
 
     In versions of Python below Python 3.9 you import `Annotation` from `typing_extensions`.
 
@@ -44,14 +52,6 @@ To achieve that, first import:
     {!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
     ```
 
-=== "Python 3.10 and above"
-
-    In Python 3.9 or above, `Annotated` is part of the standard library, so you can import it from `typing`.
-
-    ```Python hl_lines="1  3"
-    {!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
-    ```
-
 ## Use `Annotated` in the type for the `q` parameter
 
 Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations){.internal-link target=_blank}?
@@ -60,30 +60,30 @@ Now it's the time to use it with FastAPI. 🚀
 
 We had this type annotation:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    q: Union[str, None] = None
+    q: str | None = None
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    q: str | None = None
+    q: Union[str, None] = None
     ```
 
 What we will do is wrap that with `Annotated`, so it becomes:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    q: Annotated[Union[str, None]] = None
+    q: Annotated[str | None] = None
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    q: Annotated[str | None] = None
+    q: Annotated[Union[str, None]] = None
     ```
 
 Both of those versions mean the same thing, `q` is a parameter that can be a `str` or `None`, and by default, it is `None`.
@@ -94,16 +94,16 @@ Now let's jump to the fun stuff. 🎉
 
 Now that we have this `Annotated` where we can put more metadata, add `Query` to it, and set the parameter `max_length` to 50:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
     ```
 
 Notice that the default value is still `None`, so the parameter is still optional.
@@ -125,16 +125,16 @@ Previous versions of FastAPI (before <abbr title="before 2023-03">0.95.0</abbr>)
 
 This is how you would use `Query()` as the default value of your function parameter, setting the parameter `max_length` to 50:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
     ```
 
 As in this case (without using `Annotated`) we have to replace the default value `None` in the function with `Query()`, we now need to set the default value with the parameter `Query(default=None)`, it serves the same purpose of defining that default value (at least for FastAPI).
@@ -232,80 +232,80 @@ Because `Annotated` can have more than one metadata annotation, you could now ev
 
 You can also add a parameter `min_length`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="10"
     {!> ../../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial003_an_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial003.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial003.py!}
     ```
 
 ## Add regular expressions
 
 You can define a <abbr title="A regular expression, regex or regexp is a sequence of characters that define a search pattern for strings.">regular expression</abbr> that the parameter should match:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/query_params_str_validations/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11"
     {!> ../../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/query_params_str_validations/tutorial004_an_py310.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/query_params_str_validations/tutorial004.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/query_params_str_validations/tutorial004.py!}
     ```
 
 This specific regular expression checks that the received parameter value:
@@ -324,19 +324,19 @@ You can, of course, use default values other than `None`.
 
 Let's say that you want to declare the `q` query parameter to have a `min_length` of `3`, and to have a default value of `"fixedquery"`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
     ```
 
-=== "non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -378,19 +378,19 @@ But we are now declaring it with `Query`, for example like:
 
 So, when you need to declare a value as required while using `Query`, you can simply not declare a default value:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -408,19 +408,19 @@ So, when you need to declare a value as required while using `Query`, you can si
 
 There's an alternative way to explicitly declare that a value is required. You can set the default to the literal value `...`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -442,40 +442,40 @@ You can declare that a parameter can accept `None`, but that it's still required
 
 To do that, you can declare that `None` is a valid type but still use `...` as the default:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006c.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006c.py!}
     ```
 
 !!! tip
@@ -485,19 +485,19 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
 
 If you feel uncomfortable using `...`, you can also import and use `Required` from Pydantic:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="2  9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006d_an.py!}
+    ```Python hl_lines="4  10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006d_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial006d_an_py39.py!}
+    ```Python hl_lines="2  9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial006d_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -515,34 +515,34 @@ When you define a query parameter explicitly with `Query` you can also declare i
 
 For example, to declare a query parameter `q` that can appear multiple times in the URL, you can write:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial011_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial011_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial011.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial011_py310.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -551,13 +551,13 @@ For example, to declare a query parameter `q` that can appear multiple times in
     {!> ../../../docs_src/query_params_str_validations/tutorial011_py39.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial011_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial011.py!}
     ```
 
 Then, with a URL like:
@@ -590,34 +590,34 @@ The interactive API docs will update accordingly, to allow multiple values:
 
 And you can also define a default `list` of values if none are provided:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial012.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial012.py!}
     ```
 
 If you go to:
@@ -641,19 +641,19 @@ the default of `q` will be: `["foo", "bar"]` and your response will be:
 
 You can also use `list` directly instead of `List[str]` (or `list[str]` in Python 3.9+):
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -680,79 +680,78 @@ That information will be included in the generated OpenAPI and used by the docum
 
 You can add a `title`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial007_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="10"
     {!> ../../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial007_an_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial007.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial007.py!}
     ```
 
-
 And a `description`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15"
-    {!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
+    ```Python hl_lines="14"
+    {!> ../../../docs_src/query_params_str_validations/tutorial008_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="14"
     {!> ../../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="14"
-    {!> ../../../docs_src/query_params_str_validations/tutorial008_an_py310.py!}
+    ```Python hl_lines="15"
+    {!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/query_params_str_validations/tutorial008.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/query_params_str_validations/tutorial008.py!}
     ```
 
 ## Alias parameters
@@ -773,40 +772,40 @@ But you still need it to be exactly `item-query`...
 
 Then you can declare an `alias`, and that alias is what will be used to find the parameter value:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial009_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial009_an_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params_str_validations/tutorial009.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params_str_validations/tutorial009.py!}
     ```
 
 ## Deprecating parameters
@@ -817,40 +816,40 @@ You have to leave it there a while because there are clients using it, but you w
 
 Then pass the parameter `deprecated=True` to `Query`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/query_params_str_validations/tutorial010_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19"
     {!> ../../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/query_params_str_validations/tutorial010_an_py310.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/query_params_str_validations/tutorial010.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/query_params_str_validations/tutorial010.py!}
     ```
 
 The docs will show it like this:
@@ -861,40 +860,40 @@ The docs will show it like this:
 
 To exclude a query parameter from the generated OpenAPI schema (and thus, from the automatic documentation systems), set the parameter `include_in_schema` of `Query` to `False`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial014_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="10"
     {!> ../../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial014_an_py310.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params_str_validations/tutorial014.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params_str_validations/tutorial014.py!}
     ```
 
 ## Recap
index eec55502a3d16a194af386ed161d5ed7a881715d..0b74b10f81c8c2e83bee1baabe84ade3f9ee9355 100644 (file)
@@ -63,16 +63,16 @@ The parameter values in your function will be:
 
 The same way, you can declare optional query parameters, by setting their default to `None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params/tutorial002.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params/tutorial002_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params/tutorial002.py!}
     ```
 
 In this case, the function parameter `q` will be optional, and will be `None` by default.
@@ -84,16 +84,16 @@ In this case, the function parameter `q` will be optional, and will be `None` by
 
 You can also declare `bool` types, and they will be converted:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params/tutorial003.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params/tutorial003_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params/tutorial003.py!}
     ```
 
 In this case, if you go to:
@@ -137,16 +137,16 @@ And you don't have to declare them in any specific order.
 
 They will be detected by name:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="8  10"
-    {!> ../../../docs_src/query_params/tutorial004.py!}
+    ```Python hl_lines="6  8"
+    {!> ../../../docs_src/query_params/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6  8"
-    {!> ../../../docs_src/query_params/tutorial004_py310.py!}
+    ```Python hl_lines="8  10"
+    {!> ../../../docs_src/query_params/tutorial004.py!}
     ```
 
 ## Required query parameters
@@ -203,16 +203,16 @@ http://127.0.0.1:8000/items/foo-item?needy=sooooneedy
 
 And of course, you can define some parameters as required, some as having a default value, and some entirely optional:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params/tutorial006.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params/tutorial006_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params/tutorial006_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params/tutorial006.py!}
     ```
 
 In this case, there are 3 query parameters:
index 666de76eb238709ac5d10afc116c814365c65d43..bc7474359bb0627f62377f834ffb0b6d6dcb7805 100644 (file)
@@ -13,19 +13,19 @@ You can define files to be uploaded by the client using `File`.
 
 Import `File` and `UploadFile` from `fastapi`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/request_files/tutorial001_an.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/request_files/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -38,19 +38,19 @@ Import `File` and `UploadFile` from `fastapi`:
 
 Create file parameters the same way you would for `Body` or `Form`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/request_files/tutorial001_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/request_files/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -79,19 +79,19 @@ But there are several cases in which you might benefit from using `UploadFile`.
 
 Define a file parameter with a type of `UploadFile`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="13"
-    {!> ../../../docs_src/request_files/tutorial001_an.py!}
+    ```Python hl_lines="14"
+    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="14"
-    {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
+    ```Python hl_lines="13"
+    {!> ../../../docs_src/request_files/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -169,60 +169,59 @@ The way HTML forms (`<form></form>`) sends the data to the server normally uses
 
 You can make a file optional by using standard type annotations and setting a default value of `None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10  18"
-    {!> ../../../docs_src/request_files/tutorial001_02_an.py!}
+    ```Python hl_lines="9  17"
+    {!> ../../../docs_src/request_files/tutorial001_02_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9  17"
     {!> ../../../docs_src/request_files/tutorial001_02_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9  17"
-    {!> ../../../docs_src/request_files/tutorial001_02_an_py310.py!}
+    ```Python hl_lines="10  18"
+    {!> ../../../docs_src/request_files/tutorial001_02_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9  17"
-    {!> ../../../docs_src/request_files/tutorial001_02.py!}
+    ```Python hl_lines="7  15"
+    {!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7  15"
-    {!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
+    ```Python hl_lines="9  17"
+    {!> ../../../docs_src/request_files/tutorial001_02.py!}
     ```
 
-
 ## `UploadFile` with Additional Metadata
 
 You can also use `File()` with `UploadFile`, for example, to set additional metadata:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8  14"
-    {!> ../../../docs_src/request_files/tutorial001_03_an.py!}
+    ```Python hl_lines="9  15"
+    {!> ../../../docs_src/request_files/tutorial001_03_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9  15"
-    {!> ../../../docs_src/request_files/tutorial001_03_an_py39.py!}
+    ```Python hl_lines="8  14"
+    {!> ../../../docs_src/request_files/tutorial001_03_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -239,34 +238,34 @@ They would be associated to the same "form field" sent using "form data".
 
 To use that, declare a list of `bytes` or `UploadFile`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="11  16"
-    {!> ../../../docs_src/request_files/tutorial002_an.py!}
+    ```Python hl_lines="10  15"
+    {!> ../../../docs_src/request_files/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10  15"
-    {!> ../../../docs_src/request_files/tutorial002_an_py39.py!}
+    ```Python hl_lines="11  16"
+    {!> ../../../docs_src/request_files/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="10  15"
-    {!> ../../../docs_src/request_files/tutorial002.py!}
+    ```Python hl_lines="8  13"
+    {!> ../../../docs_src/request_files/tutorial002_py39.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="8  13"
-    {!> ../../../docs_src/request_files/tutorial002_py39.py!}
+    ```Python hl_lines="10  15"
+    {!> ../../../docs_src/request_files/tutorial002.py!}
     ```
 
 You will receive, as declared, a `list` of `bytes` or `UploadFile`s.
@@ -280,34 +279,34 @@ You will receive, as declared, a `list` of `bytes` or `UploadFile`s.
 
 And the same way as before, you can use `File()` to set additional parameters, even for `UploadFile`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="12  19-21"
-    {!> ../../../docs_src/request_files/tutorial003_an.py!}
+    ```Python hl_lines="11  18-20"
+    {!> ../../../docs_src/request_files/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11  18-20"
-    {!> ../../../docs_src/request_files/tutorial003_an_py39.py!}
+    ```Python hl_lines="12  19-21"
+    {!> ../../../docs_src/request_files/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.9+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="11  18"
-    {!> ../../../docs_src/request_files/tutorial003.py!}
+    ```Python hl_lines="9  16"
+    {!> ../../../docs_src/request_files/tutorial003_py39.py!}
     ```
 
-=== "Python 3.9 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="9  16"
-    {!> ../../../docs_src/request_files/tutorial003_py39.py!}
+    ```Python hl_lines="11  18"
+    {!> ../../../docs_src/request_files/tutorial003.py!}
     ```
 
 ## Recap
index 9729ab1604a6a3624e6ec60d854b6e9ed8dcc4a8..9900068fc1a917f783619dbdc062540f4a292983 100644 (file)
@@ -9,19 +9,19 @@ You can define files and form fields at the same time using `File` and `Form`.
 
 ## Import `File` and `Form`
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -34,19 +34,19 @@ You can define files and form fields at the same time using `File` and `Form`.
 
 Create file and form parameters the same way you would for `Body` or `Query`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9-11"
-    {!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
+    ```Python hl_lines="10-12"
+    {!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="10-12"
-    {!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
+    ```Python hl_lines="9-11"
+    {!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 3f866410a5f4b480e593ef67dd8846e8ee73c3c5..c3a0efe39b7e4ec35453d4e7ceb10cc99862dde7 100644 (file)
@@ -11,19 +11,19 @@ When you need to receive form fields instead of JSON, you can use `Form`.
 
 Import `Form` from `fastapi`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/request_forms/tutorial001_an.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/request_forms/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -36,19 +36,19 @@ Import `Form` from `fastapi`:
 
 Create form parameters the same way you would for `Body` or `Query`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/request_forms/tutorial001_an.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/request_forms/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index cd7a749d4da0a6baab695c2758780980114c24eb..2181cfb5ae7bb7a1d02db59ff1f27446abc49fa1 100644 (file)
@@ -4,22 +4,22 @@ You can declare the type used for the response by annotating the *path operation
 
 You can use **type annotations** the same way you would for input data in function **parameters**, you can use Pydantic models, lists, dictionaries, scalar values like integers, booleans, etc.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="18  23"
-    {!> ../../../docs_src/response_model/tutorial001_01.py!}
+    ```Python hl_lines="16  21"
+    {!> ../../../docs_src/response_model/tutorial001_01_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="18  23"
     {!> ../../../docs_src/response_model/tutorial001_01_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="16  21"
-    {!> ../../../docs_src/response_model/tutorial001_01_py310.py!}
+    ```Python hl_lines="18  23"
+    {!> ../../../docs_src/response_model/tutorial001_01.py!}
     ```
 
 FastAPI will use this return type to:
@@ -53,22 +53,22 @@ You can use the `response_model` parameter in any of the *path operations*:
 * `@app.delete()`
 * etc.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="17  22  24-27"
-    {!> ../../../docs_src/response_model/tutorial001.py!}
+    {!> ../../../docs_src/response_model/tutorial001_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="17  22  24-27"
     {!> ../../../docs_src/response_model/tutorial001_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="17  22  24-27"
-    {!> ../../../docs_src/response_model/tutorial001_py310.py!}
+    {!> ../../../docs_src/response_model/tutorial001.py!}
     ```
 
 !!! note
@@ -95,16 +95,16 @@ You can also use `response_model=None` to disable creating a response model for
 
 Here we are declaring a `UserIn` model, it will contain a plaintext password:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9  11"
-    {!> ../../../docs_src/response_model/tutorial002.py!}
+    ```Python hl_lines="7  9"
+    {!> ../../../docs_src/response_model/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  9"
-    {!> ../../../docs_src/response_model/tutorial002_py310.py!}
+    ```Python hl_lines="9  11"
+    {!> ../../../docs_src/response_model/tutorial002.py!}
     ```
 
 !!! info
@@ -115,16 +115,16 @@ Here we are declaring a `UserIn` model, it will contain a plaintext password:
 
 And we are using this model to declare our input and the same model to declare our output:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/response_model/tutorial002.py!}
+    ```Python hl_lines="16"
+    {!> ../../../docs_src/response_model/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="16"
-    {!> ../../../docs_src/response_model/tutorial002_py310.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/response_model/tutorial002.py!}
     ```
 
 Now, whenever a browser is creating a user with a password, the API will return the same password in the response.
@@ -140,44 +140,44 @@ But if we use the same model for another *path operation*, we could be sending o
 
 We can instead create an input model with the plaintext password and an output model without it:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="9  11  16"
-    {!> ../../../docs_src/response_model/tutorial003.py!}
+    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="9  11  16"
-    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
+    {!> ../../../docs_src/response_model/tutorial003.py!}
     ```
 
 Here, even though our *path operation function* is returning the same input user that contains the password:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="24"
-    {!> ../../../docs_src/response_model/tutorial003.py!}
+    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="24"
-    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
+    {!> ../../../docs_src/response_model/tutorial003.py!}
     ```
 
 ...we declared the `response_model` to be our model `UserOut`, that doesn't include the password:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python hl_lines="22"
-    {!> ../../../docs_src/response_model/tutorial003.py!}
+    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python hl_lines="22"
-    {!> ../../../docs_src/response_model/tutorial003_py310.py!}
+    {!> ../../../docs_src/response_model/tutorial003.py!}
     ```
 
 So, **FastAPI** will take care of filtering out all the data that is not declared in the output model (using Pydantic).
@@ -202,16 +202,16 @@ But in most of the cases where we need to do something like this, we want the mo
 
 And in those cases, we can use classes and inheritance to take advantage of function **type annotations** to get better support in the editor and tools, and still get the FastAPI **data filtering**.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9-13  15-16  20"
-    {!> ../../../docs_src/response_model/tutorial003_01.py!}
+    ```Python hl_lines="7-10  13-14  18"
+    {!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7-10  13-14  18"
-    {!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
+    ```Python hl_lines="9-13  15-16  20"
+    {!> ../../../docs_src/response_model/tutorial003_01.py!}
     ```
 
 With this, we get tooling support, from editors and mypy as this code is correct in terms of types, but we also get the data filtering from FastAPI.
@@ -278,16 +278,16 @@ But when you return some other arbitrary object that is not a valid Pydantic typ
 
 The same would happen if you had something like a <abbr title='A union between multiple types means "any of these types".'>union</abbr> between different types where one or more of them are not valid Pydantic types, for example this would fail 💥:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/response_model/tutorial003_04.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/response_model/tutorial003_04.py!}
     ```
 
 ...this fails because the type annotation is not a Pydantic type and is not just a single `Response` class or subclass, it's a union (any of the two) between a `Response` and a `dict`.
@@ -300,16 +300,16 @@ But you might want to still keep the return type annotation in the function to g
 
 In this case, you can disable the response model generation by setting `response_model=None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/response_model/tutorial003_05.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/response_model/tutorial003_05.py!}
     ```
 
 This will make FastAPI skip the response model generation and that way you can have any return type annotations you need without it affecting your FastAPI application. 🤓
@@ -318,22 +318,22 @@ This will make FastAPI skip the response model generation and that way you can h
 
 Your response model could have default values, like:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11  13-14"
-    {!> ../../../docs_src/response_model/tutorial004.py!}
+    ```Python hl_lines="9  11-12"
+    {!> ../../../docs_src/response_model/tutorial004_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="11  13-14"
     {!> ../../../docs_src/response_model/tutorial004_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9  11-12"
-    {!> ../../../docs_src/response_model/tutorial004_py310.py!}
+    ```Python hl_lines="11  13-14"
+    {!> ../../../docs_src/response_model/tutorial004.py!}
     ```
 
 * `description: Union[str, None] = None` (or `str | None = None` in Python 3.10) has a default of `None`.
@@ -348,22 +348,22 @@ For example, if you have models with many optional attributes in a NoSQL databas
 
 You can set the *path operation decorator* parameter `response_model_exclude_unset=True`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="24"
-    {!> ../../../docs_src/response_model/tutorial004.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/response_model/tutorial004_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="24"
     {!> ../../../docs_src/response_model/tutorial004_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/response_model/tutorial004_py310.py!}
+    ```Python hl_lines="24"
+    {!> ../../../docs_src/response_model/tutorial004.py!}
     ```
 
 and those default values won't be included in the response, only the values actually set.
@@ -441,16 +441,16 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
 
     This also applies to `response_model_by_alias` that works similarly.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="31  37"
-    {!> ../../../docs_src/response_model/tutorial005.py!}
+    ```Python hl_lines="29  35"
+    {!> ../../../docs_src/response_model/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="29  35"
-    {!> ../../../docs_src/response_model/tutorial005_py310.py!}
+    ```Python hl_lines="31  37"
+    {!> ../../../docs_src/response_model/tutorial005.py!}
     ```
 
 !!! tip
@@ -462,16 +462,16 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
 
 If you forget to use a `set` and use a `list` or `tuple` instead, FastAPI will still convert it to a `set` and it will work correctly:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="31  37"
-    {!> ../../../docs_src/response_model/tutorial006.py!}
+    ```Python hl_lines="29  35"
+    {!> ../../../docs_src/response_model/tutorial006_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="29  35"
-    {!> ../../../docs_src/response_model/tutorial006_py310.py!}
+    ```Python hl_lines="31  37"
+    {!> ../../../docs_src/response_model/tutorial006.py!}
     ```
 
 ## Recap
index d2aa668433a4b3d6c90c25d597e87e1c997384ab..705ab567124802a004e4410db7575695fe25f4c9 100644 (file)
@@ -8,16 +8,16 @@ Here are several ways to do it.
 
 You can declare an `example` for a Pydantic model using `Config` and `schema_extra`, as described in <a href="https://pydantic-docs.helpmanual.io/usage/schema/#schema-customization" class="external-link" target="_blank">Pydantic's docs: Schema customization</a>:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15-23"
-    {!> ../../../docs_src/schema_extra_example/tutorial001.py!}
+    ```Python hl_lines="13-21"
+    {!> ../../../docs_src/schema_extra_example/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13-21"
-    {!> ../../../docs_src/schema_extra_example/tutorial001_py310.py!}
+    ```Python hl_lines="15-23"
+    {!> ../../../docs_src/schema_extra_example/tutorial001.py!}
     ```
 
 That extra info will be added as-is to the output **JSON Schema** for that model, and it will be used in the API docs.
@@ -33,16 +33,16 @@ When using `Field()` with Pydantic models, you can also declare extra info for t
 
 You can use this to add `example` for each field:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4  10-13"
-    {!> ../../../docs_src/schema_extra_example/tutorial002.py!}
+    ```Python hl_lines="2  8-11"
+    {!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="2  8-11"
-    {!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
+    ```Python hl_lines="4  10-13"
+    {!> ../../../docs_src/schema_extra_example/tutorial002.py!}
     ```
 
 !!! warning
@@ -66,25 +66,31 @@ you can also declare a data `example` or a group of `examples` with additional i
 
 Here we pass an `example` of the data expected in `Body()`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="23-28"
-    {!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
+    ```Python hl_lines="22-27"
+    {!> ../../../docs_src/schema_extra_example/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="22-27"
     {!> ../../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="22-27"
-    {!> ../../../docs_src/schema_extra_example/tutorial003_an_py310.py!}
+    ```Python hl_lines="23-28"
+    {!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
+    ```
+
+=== "Python 3.10+ non-Annotated"
+
+    ```Python hl_lines="18-23"
+    {!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -93,12 +99,6 @@ Here we pass an `example` of the data expected in `Body()`:
     {!> ../../../docs_src/schema_extra_example/tutorial003.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
-
-    ```Python hl_lines="18-23"
-    {!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
-    ```
-
 ### Example in the docs UI
 
 With any of the methods above it would look like this in the `/docs`:
@@ -118,25 +118,31 @@ Each specific example `dict` in the `examples` can contain:
 * `value`: This is the actual example shown, e.g. a `dict`.
 * `externalValue`: alternative to `value`, a URL pointing to the example. Although this might not be supported by as many tools as `value`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="24-50"
-    {!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
+    ```Python hl_lines="23-49"
+    {!> ../../../docs_src/schema_extra_example/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="23-49"
     {!> ../../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="23-49"
-    {!> ../../../docs_src/schema_extra_example/tutorial004_an_py310.py!}
+    ```Python hl_lines="24-50"
+    {!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
+
+    ```Python hl_lines="19-45"
+    {!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
+    ```
+
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -145,12 +151,6 @@ Each specific example `dict` in the `examples` can contain:
     {!> ../../../docs_src/schema_extra_example/tutorial004.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
-
-    ```Python hl_lines="19-45"
-    {!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
-    ```
-
 ### Examples in the docs UI
 
 With `examples` added to `Body()` the `/docs` would look like:
index 9198db6a610f07ce5659e5d0068da226704678b5..a82809b967635a561fd44d1253fa6748e054853f 100644 (file)
@@ -20,19 +20,19 @@ Let's first just use the code and see how it works, and then we'll come back to
 
 Copy the example in a file `main.py`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python
-    {!> ../../../docs_src/security/tutorial001_an.py!}
+    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
+    {!> ../../../docs_src/security/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -134,19 +134,19 @@ In this example we are going to use **OAuth2**, with the **Password** flow, usin
 
 When we create an instance of the `OAuth2PasswordBearer` class we pass in the `tokenUrl` parameter. This parameter contains the URL that the client (the frontend running in the user's browser) will use to send the `username` and `password` in order to get a token.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python  hl_lines="7"
-    {!> ../../../docs_src/security/tutorial001_an.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
+    ```Python  hl_lines="7"
+    {!> ../../../docs_src/security/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -185,19 +185,19 @@ So, it can be used with `Depends`.
 
 Now you can pass that `oauth2_scheme` in a dependency with `Depends`.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python  hl_lines="11"
-    {!> ../../../docs_src/security/tutorial001_an.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
+    ```Python  hl_lines="11"
+    {!> ../../../docs_src/security/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
index 0076e7d16184febace54916cc494cea8ff4177e5..3d63583407d9c03bffb2e3a0e5a08dceae93ef30 100644 (file)
@@ -2,19 +2,19 @@
 
 In the previous chapter the security system (which is based on the dependency injection system) was giving the *path operation function* a `token` as a `str`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="11"
-    {!> ../../../docs_src/security/tutorial001_an.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
-    {!> ../../../docs_src/security/tutorial001_an_py39.py!}
+    ```Python hl_lines="11"
+    {!> ../../../docs_src/security/tutorial001_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
@@ -33,40 +33,40 @@ First, let's create a Pydantic user model.
 
 The same way we use Pydantic to declare bodies, we can use it anywhere else:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="5  13-17"
-    {!> ../../../docs_src/security/tutorial002_an.py!}
+    ```Python hl_lines="5  12-16"
+    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="5  12-16"
     {!> ../../../docs_src/security/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="5  12-16"
-    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
+    ```Python hl_lines="5  13-17"
+    {!> ../../../docs_src/security/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="5  12-16"
-    {!> ../../../docs_src/security/tutorial002.py!}
+    ```Python hl_lines="3  10-14"
+    {!> ../../../docs_src/security/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3  10-14"
-    {!> ../../../docs_src/security/tutorial002_py310.py!}
+    ```Python hl_lines="5  12-16"
+    {!> ../../../docs_src/security/tutorial002.py!}
     ```
 
 ## Create a `get_current_user` dependency
@@ -79,120 +79,120 @@ Remember that dependencies can have sub-dependencies?
 
 The same as we were doing before in the *path operation* directly, our new dependency `get_current_user` will receive a `token` as a `str` from the sub-dependency `oauth2_scheme`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="26"
-    {!> ../../../docs_src/security/tutorial002_an.py!}
+    ```Python hl_lines="25"
+    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="25"
     {!> ../../../docs_src/security/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="25"
-    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
+    ```Python hl_lines="26"
+    {!> ../../../docs_src/security/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="25"
-    {!> ../../../docs_src/security/tutorial002.py!}
+    ```Python hl_lines="23"
+    {!> ../../../docs_src/security/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="23"
-    {!> ../../../docs_src/security/tutorial002_py310.py!}
+    ```Python hl_lines="25"
+    {!> ../../../docs_src/security/tutorial002.py!}
     ```
 
 ## Get the user
 
 `get_current_user` will use a (fake) utility function we created, that takes a token as a `str` and returns our Pydantic `User` model:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="20-23  27-28"
-    {!> ../../../docs_src/security/tutorial002_an.py!}
+    ```Python hl_lines="19-22  26-27"
+    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="19-22  26-27"
     {!> ../../../docs_src/security/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="19-22  26-27"
-    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
+    ```Python hl_lines="20-23  27-28"
+    {!> ../../../docs_src/security/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="19-22  26-27"
-    {!> ../../../docs_src/security/tutorial002.py!}
+    ```Python hl_lines="17-20  24-25"
+    {!> ../../../docs_src/security/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="17-20  24-25"
-    {!> ../../../docs_src/security/tutorial002_py310.py!}
+    ```Python hl_lines="19-22  26-27"
+    {!> ../../../docs_src/security/tutorial002.py!}
     ```
 
 ## Inject the current user
 
 So now we can use the same `Depends` with our `get_current_user` in the *path operation*:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="32"
-    {!> ../../../docs_src/security/tutorial002_an.py!}
+    ```Python hl_lines="31"
+    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="31"
     {!> ../../../docs_src/security/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="31"
-    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
+    ```Python hl_lines="32"
+    {!> ../../../docs_src/security/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="31"
-    {!> ../../../docs_src/security/tutorial002.py!}
+    ```Python hl_lines="29"
+    {!> ../../../docs_src/security/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="29"
-    {!> ../../../docs_src/security/tutorial002_py310.py!}
+    ```Python hl_lines="31"
+    {!> ../../../docs_src/security/tutorial002.py!}
     ```
 
 Notice that we declare the type of `current_user` as the Pydantic model `User`.
@@ -241,40 +241,40 @@ And all of them (or any portion of them that you want) can take the advantage of
 
 And all these thousands of *path operations* can be as small as 3 lines:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="31-33"
-    {!> ../../../docs_src/security/tutorial002_an.py!}
+    ```Python hl_lines="30-32"
+    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="30-32"
     {!> ../../../docs_src/security/tutorial002_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="30-32"
-    {!> ../../../docs_src/security/tutorial002_an_py310.py!}
+    ```Python hl_lines="31-33"
+    {!> ../../../docs_src/security/tutorial002_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="30-32"
-    {!> ../../../docs_src/security/tutorial002.py!}
+    ```Python hl_lines="28-30"
+    {!> ../../../docs_src/security/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="28-30"
-    {!> ../../../docs_src/security/tutorial002_py310.py!}
+    ```Python hl_lines="30-32"
+    {!> ../../../docs_src/security/tutorial002.py!}
     ```
 
 ## Recap
index 0b639097564faebdd0249d50010cd83a0f592393..e6c0f1738f2bc06522472a51f7749a7949ed38a0 100644 (file)
@@ -109,40 +109,40 @@ And another utility to verify if a received password matches the hash stored.
 
 And another one to authenticate and return a user.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="7  49  56-57  60-61  70-76"
-    {!> ../../../docs_src/security/tutorial004_an.py!}
+    ```Python hl_lines="7  48  55-56  59-60  69-75"
+    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="7  48  55-56  59-60  69-75"
     {!> ../../../docs_src/security/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  48  55-56  59-60  69-75"
-    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
+    ```Python hl_lines="7  49  56-57  60-61  70-76"
+    {!> ../../../docs_src/security/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="7  48  55-56  59-60  69-75"
-    {!> ../../../docs_src/security/tutorial004.py!}
+    ```Python hl_lines="6  47  54-55  58-59  68-74"
+    {!> ../../../docs_src/security/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="6  47  54-55  58-59  68-74"
-    {!> ../../../docs_src/security/tutorial004_py310.py!}
+    ```Python hl_lines="7  48  55-56  59-60  69-75"
+    {!> ../../../docs_src/security/tutorial004.py!}
     ```
 
 !!! note
@@ -176,40 +176,40 @@ Define a Pydantic Model that will be used in the token endpoint for the response
 
 Create a utility function to generate a new access token.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="6  13-15  29-31 79-87"
-    {!> ../../../docs_src/security/tutorial004_an.py!}
+    ```Python hl_lines="6  12-14  28-30  78-86"
+    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="6  12-14  28-30  78-86"
     {!> ../../../docs_src/security/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6  12-14  28-30  78-86"
-    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
+    ```Python hl_lines="6  13-15  29-31 79-87"
+    {!> ../../../docs_src/security/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="6  12-14  28-30  78-86"
-    {!> ../../../docs_src/security/tutorial004.py!}
+    ```Python hl_lines="5  11-13  27-29  77-85"
+    {!> ../../../docs_src/security/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="5  11-13  27-29  77-85"
-    {!> ../../../docs_src/security/tutorial004_py310.py!}
+    ```Python hl_lines="6  12-14  28-30  78-86"
+    {!> ../../../docs_src/security/tutorial004.py!}
     ```
 
 ## Update the dependencies
@@ -220,82 +220,82 @@ Decode the received token, verify it, and return the current user.
 
 If the token is invalid, return an HTTP error right away.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="90-107"
-    {!> ../../../docs_src/security/tutorial004_an.py!}
+    ```Python hl_lines="89-106"
+    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="89-106"
     {!> ../../../docs_src/security/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="89-106"
-    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
+    ```Python hl_lines="90-107"
+    {!> ../../../docs_src/security/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="89-106"
-    {!> ../../../docs_src/security/tutorial004.py!}
+    ```Python hl_lines="88-105"
+    {!> ../../../docs_src/security/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="88-105"
-    {!> ../../../docs_src/security/tutorial004_py310.py!}
+    ```Python hl_lines="89-106"
+    {!> ../../../docs_src/security/tutorial004.py!}
     ```
 
 ## Update the `/token` *path operation*
 
 Create a `timedelta` with the expiration time of the token.
 
-Create a real JWT access token and return it.
+Create a real JWT access token and return it
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="118-133"
-    {!> ../../../docs_src/security/tutorial004_an.py!}
+    ```Python hl_lines="117-132"
+    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="117-132"
     {!> ../../../docs_src/security/tutorial004_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="117-132"
-    {!> ../../../docs_src/security/tutorial004_an_py310.py!}
+    ```Python hl_lines="118-133"
+    {!> ../../../docs_src/security/tutorial004_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="115-128"
-    {!> ../../../docs_src/security/tutorial004.py!}
+    ```Python hl_lines="114-127"
+    {!> ../../../docs_src/security/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="114-127"
-    {!> ../../../docs_src/security/tutorial004_py310.py!}
+    ```Python hl_lines="115-128"
+    {!> ../../../docs_src/security/tutorial004.py!}
     ```
 
 ### Technical details about the JWT "subject" `sub`
index 6abf43218019bde7468958eb7f85e22120e88b1a..9534185c79aafc7a5819305eb018f18bffc7e149 100644 (file)
@@ -49,40 +49,40 @@ Now let's use the utilities provided by **FastAPI** to handle this.
 
 First, import `OAuth2PasswordRequestForm`, and use it as a dependency with `Depends` in the *path operation* for `/token`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4  79"
-    {!> ../../../docs_src/security/tutorial003_an.py!}
+    ```Python hl_lines="4  78"
+    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="4  78"
     {!> ../../../docs_src/security/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  78"
-    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
+    ```Python hl_lines="4  79"
+    {!> ../../../docs_src/security/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="4  76"
-    {!> ../../../docs_src/security/tutorial003.py!}
+    ```Python hl_lines="2  74"
+    {!> ../../../docs_src/security/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="2  74"
-    {!> ../../../docs_src/security/tutorial003_py310.py!}
+    ```Python hl_lines="4  76"
+    {!> ../../../docs_src/security/tutorial003.py!}
     ```
 
 `OAuth2PasswordRequestForm` is a class dependency that declares a form body with:
@@ -122,40 +122,40 @@ If there is no such user, we return an error saying "incorrect username or passw
 
 For the error, we use the exception `HTTPException`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3  80-82"
-    {!> ../../../docs_src/security/tutorial003_an.py!}
+    ```Python hl_lines="3  79-81"
+    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3  79-81"
     {!> ../../../docs_src/security/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="3  79-81"
-    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
+    ```Python hl_lines="3  80-82"
+    {!> ../../../docs_src/security/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="3  77-79"
-    {!> ../../../docs_src/security/tutorial003.py!}
+    ```Python hl_lines="1  75-77"
+    {!> ../../../docs_src/security/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="1  75-77"
-    {!> ../../../docs_src/security/tutorial003_py310.py!}
+    ```Python hl_lines="3  77-79"
+    {!> ../../../docs_src/security/tutorial003.py!}
     ```
 
 ### Check the password
@@ -182,40 +182,40 @@ If your database is stolen, the thief won't have your users' plaintext passwords
 
 So, the thief won't be able to try to use those same passwords in another system (as many users use the same password everywhere, this would be dangerous).
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="83-86"
-    {!> ../../../docs_src/security/tutorial003_an.py!}
+    ```Python hl_lines="82-85"
+    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="82-85"
     {!> ../../../docs_src/security/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="82-85"
-    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
+    ```Python hl_lines="83-86"
+    {!> ../../../docs_src/security/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="80-83"
-    {!> ../../../docs_src/security/tutorial003.py!}
+    ```Python hl_lines="78-81"
+    {!> ../../../docs_src/security/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="78-81"
-    {!> ../../../docs_src/security/tutorial003_py310.py!}
+    ```Python hl_lines="80-83"
+    {!> ../../../docs_src/security/tutorial003.py!}
     ```
 
 #### About `**user_dict`
@@ -252,40 +252,40 @@ For this simple example, we are going to just be completely insecure and return
 
     But for now, let's focus on the specific details we need.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="88"
-    {!> ../../../docs_src/security/tutorial003_an.py!}
+    ```Python hl_lines="87"
+    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="87"
     {!> ../../../docs_src/security/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="87"
-    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
+    ```Python hl_lines="88"
+    {!> ../../../docs_src/security/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="85"
-    {!> ../../../docs_src/security/tutorial003.py!}
+    ```Python hl_lines="83"
+    {!> ../../../docs_src/security/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="83"
-    {!> ../../../docs_src/security/tutorial003_py310.py!}
+    ```Python hl_lines="85"
+    {!> ../../../docs_src/security/tutorial003.py!}
     ```
 
 !!! tip
@@ -309,40 +309,40 @@ Both of these dependencies will just return an HTTP error if the user doesn't ex
 
 So, in our endpoint, we will only get a user if the user exists, was correctly authenticated, and is active:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="59-67  70-75  95"
-    {!> ../../../docs_src/security/tutorial003_an.py!}
+    ```Python hl_lines="58-66  69-74  94"
+    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="58-66  69-74  94"
     {!> ../../../docs_src/security/tutorial003_an_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="58-66  69-74  94"
-    {!> ../../../docs_src/security/tutorial003_an_py310.py!}
+    ```Python hl_lines="59-67  70-75  95"
+    {!> ../../../docs_src/security/tutorial003_an.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="58-66  69-72  90"
-    {!> ../../../docs_src/security/tutorial003.py!}
+    ```Python hl_lines="56-64  67-70  88"
+    {!> ../../../docs_src/security/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
-    ```Python hl_lines="56-64  67-70  88"
-    {!> ../../../docs_src/security/tutorial003_py310.py!}
+    ```Python hl_lines="58-66  69-72  90"
+    {!> ../../../docs_src/security/tutorial003.py!}
     ```
 
 !!! info
index 5ccaf05ecec968f90c4897b72bf829db8dc388f7..fd66c5add072020675b5a03be23b28c82a14eb15 100644 (file)
@@ -262,22 +262,22 @@ So, the user will also have a `password` when creating it.
 
 But for security, the `password` won't be in other Pydantic *models*, for example, it won't be sent from the API when reading a user.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3  6-8  11-12  23-24  27-28"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="1  4-6  9-10  21-22  25-26"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="3  6-8  11-12  23-24  27-28"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1  4-6  9-10  21-22  25-26"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="3  6-8  11-12  23-24  27-28"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 #### SQLAlchemy style and Pydantic style
@@ -306,22 +306,22 @@ The same way, when reading a user, we can now declare that `items` will contain
 
 Not only the IDs of those items, but all the data that we defined in the Pydantic *model* for reading items: `Item`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15-17  31-34"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="13-15  29-32"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="15-17  31-34"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13-15  29-32"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="15-17  31-34"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 !!! tip
@@ -335,22 +335,22 @@ This <a href="https://pydantic-docs.helpmanual.io/usage/model_config/" class="ex
 
 In the `Config` class, set the attribute `orm_mode = True`.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15  19-20  31  36-37"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="13  17-18  29  34-35"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="15  19-20  31  36-37"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13  17-18  29  34-35"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="15  19-20  31  36-37"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 !!! tip
@@ -481,16 +481,16 @@ And now in the file `sql_app/main.py` let's integrate and use all the other part
 
 In a very simplistic way create the database tables:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 #### Alembic Note
@@ -515,16 +515,16 @@ For that, we will create a new dependency with `yield`, as explained before in t
 
 Our dependency will create a new SQLAlchemy `SessionLocal` that will be used in a single request, and then close it once the request is finished.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="15-20"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="13-18"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13-18"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="15-20"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 !!! info
@@ -540,16 +540,16 @@ And then, when using the dependency in a *path operation function*, we declare i
 
 This will then give us better editor support inside the *path operation function*, because the editor will know that the `db` parameter is of type `Session`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="24  32  38  47  53"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="22  30  36  45  51"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="22  30  36  45  51"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="24  32  38  47  53"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 !!! info "Technical Details"
@@ -561,16 +561,16 @@ This will then give us better editor support inside the *path operation function
 
 Now, finally, here's the standard **FastAPI** *path operations* code.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="23-28  31-34  37-42  45-49  52-55"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="21-26  29-32  35-40  43-47  50-53"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="21-26  29-32  35-40  43-47  50-53"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="23-28  31-34  37-42  45-49  52-55"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 We are creating the database session before each request in the dependency with `yield`, and then closing it afterwards.
@@ -654,22 +654,22 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
 
 * `sql_app/schemas.py`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 * `sql_app/crud.py`:
@@ -680,16 +680,16 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
 
 * `sql_app/main.py`:
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 ## Check it
@@ -739,16 +739,16 @@ A "middleware" is basically a function that is always executed for each request,
 
 The middleware we'll add (just a function) will create a new SQLAlchemy `SessionLocal` for each request, add it to the request and then close it once the request is finished.
 
-=== "Python 3.6 and above"
+=== "Python 3.9+"
 
-    ```Python hl_lines="14-22"
-    {!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}
+    ```Python hl_lines="12-20"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12-20"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
+    ```Python hl_lines="14-22"
+    {!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}
     ```
 
 !!! info
index a932ad3f88b34600166006f4bc56fb089be2e23a..9f94183f4eb0fb565a4f5117628a63d69598c30a 100644 (file)
@@ -110,40 +110,40 @@ It has a `POST` operation that could return several errors.
 
 Both *path operations* require an `X-Token` header.
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b_an/main.py!}
+    {!> ../../../docs_src/app_testing/app_b_an_py310/main.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python
     {!> ../../../docs_src/app_testing/app_b_an_py39/main.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b_an_py310/main.py!}
+    {!> ../../../docs_src/app_testing/app_b_an/main.py!}
     ```
 
-=== "Python 3.6 and above - non-Annotated"
+=== "Python 3.10+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b/main.py!}
+    {!> ../../../docs_src/app_testing/app_b_py310/main.py!}
     ```
 
-=== "Python 3.10 and above - non-Annotated"
+=== "Python 3.6+ non-Annotated"
 
     !!! tip
         Try to use the main, `Annotated` version better.
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b_py310/main.py!}
+    {!> ../../../docs_src/app_testing/app_b/main.py!}
     ```
 
 ### Extended testing file
index 56f5cabac84931d4c00166205f152f6d5f37a777..037e9628fbea8115a4e26885ed2cacde4c3984d6 100644 (file)
 
 これらの *path operation* には `X-Token` ヘッダーが必要です。
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b/main.py!}
+    {!> ../../../docs_src/app_testing/app_b_py310/main.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/app_testing/app_b_py310/main.py!}
+    {!> ../../../docs_src/app_testing/app_b/main.py!}
     ```
 
 ### 拡張版テストファイル
index ac67aa47ff1d428efdca102c55940c4204e0026c..22f5856a69cce8c0fadbbcf142de209a7ffe0fb3 100644 (file)
@@ -8,16 +8,16 @@ Primeiro, é claro, você pode misturar `Path`, `Query` e declarações de parâ
 
 E você também pode declarar parâmetros de corpo como opcionais, definindo o valor padrão com `None`:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19-21"
-    {!> ../../../docs_src/body_multiple_params/tutorial001.py!}
+    ```Python hl_lines="17-19"
+    {!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17-19"
-    {!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
+    ```Python hl_lines="19-21"
+    {!> ../../../docs_src/body_multiple_params/tutorial001.py!}
     ```
 
 !!! nota
@@ -38,16 +38,16 @@ No exemplo anterior, as *operações de rota* esperariam um JSON no corpo conten
 
 Mas você pode também declarar múltiplos parâmetros de corpo, por exemplo, `item` e `user`:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="22"
-    {!> ../../../docs_src/body_multiple_params/tutorial002.py!}
+    ```Python hl_lines="20"
+    {!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="20"
-    {!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
+    ```Python hl_lines="22"
+    {!> ../../../docs_src/body_multiple_params/tutorial002.py!}
     ```
 
 Neste caso, o **FastAPI** perceberá que existe mais de um parâmetro de corpo na função (dois parâmetros que são modelos Pydantic).
@@ -87,13 +87,13 @@ Se você declará-lo como é, porque é um valor singular, o **FastAPI** assumir
 
 Mas você pode instruir o **FastAPI** para tratá-lo como outra chave do corpo usando `Body`:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.6+"
 
     ```Python hl_lines="22"
     {!> ../../../docs_src/body_multiple_params/tutorial003.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.10+"
 
     ```Python hl_lines="20"
     {!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
@@ -137,16 +137,16 @@ q: str | None = None
 
 Por exemplo:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="27"
-    {!> ../../../docs_src/body_multiple_params/tutorial004.py!}
+    ```Python hl_lines="26"
+    {!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="26"
-    {!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
+    ```Python hl_lines="27"
+    {!> ../../../docs_src/body_multiple_params/tutorial004.py!}
     ```
 
 !!! info "Informação"
@@ -166,16 +166,16 @@ item: Item = Body(embed=True)
 
 como em:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/body_multiple_params/tutorial005.py!}
+    ```Python hl_lines="15"
+    {!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="15"
-    {!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/body_multiple_params/tutorial005.py!}
     ```
 
 Neste caso o **FastAPI** esperará um corpo como:
index bb04e9ca27e8faa26d1bd93e1326ed2e391dc3f1..bb4483fdc8f0fb9fab8cd6be973f8c8c0212a802 100644 (file)
@@ -20,16 +20,16 @@ Você pode usar a função `jsonable_encoder` para resolver isso.
 
 A função recebe um objeto, como um modelo Pydantic e retorna uma versão compatível com JSON:
 
-=== "Python 3.6 e acima"
+=== "Python 3.10+"
 
-    ```Python hl_lines="5  22"
-    {!> ../../../docs_src/encoder/tutorial001.py!}
+    ```Python hl_lines="4  21"
+    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 e acima"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  21"
-    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
+    ```Python hl_lines="5  22"
+    {!> ../../../docs_src/encoder/tutorial001.py!}
     ```
 
 Neste exemplo, ele converteria o modelo Pydantic em um `dict`, e o `datetime` em um `str`.
index 94ee784cd220b28b0a0ad2e86e674e0bfbe2f206..bc8843327fb01efd5e06554c3422df10e4025bb0 100644 (file)
@@ -6,16 +6,16 @@ Você pode definir parâmetros de Cabeçalho da mesma maneira que define paramê
 
 Primeiro importe `Header`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/header_params/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/header_params/tutorial001.py!}
     ```
 
 ## Declare parâmetros de `Header`
@@ -24,16 +24,16 @@ Então declare os paramêtros de cabeçalho usando a mesma estrutura que em `Pat
 
 O primeiro valor é o valor padrão, você pode passar todas as validações adicionais ou parâmetros de anotação:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/header_params/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial001.py!}
     ```
 
 !!! note "Detalhes Técnicos"
@@ -60,16 +60,16 @@ Portanto, você pode usar `user_agent` como faria normalmente no código Python,
 
 Se por algum motivo você precisar desabilitar a conversão automática de sublinhados para hífens, defina o parâmetro `convert_underscores` de `Header` para `False`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/header_params/tutorial002.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/header_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/header_params/tutorial002_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/header_params/tutorial002.py!}
     ```
 
 !!! warning "Aviso"
@@ -85,22 +85,22 @@ Você receberá todos os valores do cabeçalho duplicado como uma `list` Python.
 
 Por exemplo, para declarar um cabeçalho de `X-Token` que pode aparecer mais de uma vez, você pode escrever:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/header_params/tutorial003.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/header_params/tutorial003_py310.py!}
     ```
 
-=== "Python 3.9 and above"
+=== "Python 3.9+"
 
     ```Python hl_lines="9"
     {!> ../../../docs_src/header_params/tutorial003_py39.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/header_params/tutorial003_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/header_params/tutorial003.py!}
     ```
 
 Se você se comunicar com essa *operação de caminho* enviando dois cabeçalhos HTTP como:
index f478fd190d2e2afac487ebd0049502e1aebf2630..ec9b74b300d2b4ac14de81bea9e9b2017297e913 100644 (file)
@@ -6,16 +6,16 @@ Do mesmo modo que você pode declarar mais validações e metadados para parâme
 
 Primeiro, importe `Path` de `fastapi`:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
     ```
 
 ## Declare metadados
@@ -24,16 +24,16 @@ Você pode declarar todos os parâmetros da mesma maneira que na `Query`.
 
 Por exemplo para declarar um valor de metadado `title` para o parâmetro de rota `item_id` você pode digitar:
 
-=== "Python 3.6 e superiores"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 e superiores"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
     ```
 
 !!! note "Nota"
index 1897243961b732c90c2305e1fcb4d8e521f7a969..3ada4fd213cb5ae6d6758ae75eae684e929706a4 100644 (file)
@@ -63,16 +63,16 @@ Os valores dos parâmetros na sua função serão:
 
 Da mesma forma, você pode declarar parâmetros de consulta opcionais, definindo o valor padrão para `None`:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params/tutorial002.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params/tutorial002_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params/tutorial002.py!}
     ```
 
 Nesse caso, o parâmetro da função `q` será opcional, e `None` será o padrão.
@@ -85,16 +85,16 @@ Nesse caso, o parâmetro da função `q` será opcional, e `None` será o padrã
 
 Você também pode declarar tipos `bool`, e eles serão convertidos:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/query_params/tutorial003.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/query_params/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/query_params/tutorial003_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/query_params/tutorial003.py!}
     ```
 
 Nesse caso, se você for para:
@@ -137,16 +137,16 @@ E você não precisa declarar eles em nenhuma ordem específica.
 
 Eles serão detectados pelo nome:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="8  10"
-    {!> ../../../docs_src/query_params/tutorial004.py!}
+    ```Python hl_lines="6  8"
+    {!> ../../../docs_src/query_params/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="6  8"
-    {!> ../../../docs_src/query_params/tutorial004_py310.py!}
+    ```Python hl_lines="8  10"
+    {!> ../../../docs_src/query_params/tutorial004.py!}
     ```
 
 ## Parâmetros de consulta obrigatórios
@@ -203,17 +203,18 @@ http://127.0.0.1:8000/items/foo-item?needy=sooooneedy
 
 E claro, você pode definir alguns parâmetros como obrigatórios, alguns possuindo um valor padrão, e outros sendo totalmente opcionais:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="10"
-    {!> ../../../docs_src/query_params/tutorial006.py!}
+    ```Python hl_lines="8"
+    {!> ../../../docs_src/query_params/tutorial006_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8"
-    {!> ../../../docs_src/query_params/tutorial006_py310.py!}
+    ```Python hl_lines="10"
+    {!> ../../../docs_src/query_params/tutorial006.py!}
     ```
+
 Nesse caso, existem 3 parâmetros de consulta:
 
 * `needy`, um `str` obrigatório.
index e608f6c8f301063bc37a8cbdc0c7f63139206da7..81efda786ad8ce5c443fb6575c076e4ed009d139 100644 (file)
 
 **FastAPI** знает, что нужно сделать в каждом случае и как переиспользовать тот же объект `BackgroundTasks`, так чтобы все фоновые задачи собрались и запустились вместе в фоне:
 
-=== "Python 3.6 и выше"
+=== "Python 3.10+"
 
-    ```Python hl_lines="13  15  22  25"
-    {!> ../../../docs_src/background_tasks/tutorial002.py!}
+    ```Python hl_lines="11  13  20  23"
+    {!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 и выше"
+=== "Python 3.6+"
 
-    ```Python hl_lines="11  13  20  23"
-    {!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
+    ```Python hl_lines="13  15  22  25"
+    {!> ../../../docs_src/background_tasks/tutorial002.py!}
     ```
 
 В этом примере сообщения будут записаны в `log.txt` *после* того, как ответ сервера был отправлен.
index e8507c1718d7e927a3b0eafd7ba929ebdf27a4bf..674b8bde47bf79bb307727c78d4bb388d0ea8ac0 100644 (file)
@@ -6,16 +6,16 @@
 
 Сначала вы должны импортировать его:
 
-=== "Python 3.6 и выше"
+=== "Python 3.10+"
 
-    ```Python hl_lines="4"
-    {!> ../../../docs_src/body_fields/tutorial001.py!}
+    ```Python hl_lines="2"
+    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 и выше"
+=== "Python 3.6+"
 
-    ```Python hl_lines="2"
-    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
+    ```Python hl_lines="4"
+    {!> ../../../docs_src/body_fields/tutorial001.py!}
     ```
 
 !!! warning "Внимание"
 
 Вы можете использовать функцию `Field` с атрибутами модели:
 
-=== "Python 3.6 и выше"
+=== "Python 3.10+"
 
-    ```Python hl_lines="11-14"
-    {!> ../../../docs_src/body_fields/tutorial001.py!}
+    ```Python hl_lines="9-12"
+    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 и выше"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9-12"
-    {!> ../../../docs_src/body_fields/tutorial001_py310.py!}
+    ```Python hl_lines="11-14"
+    {!> ../../../docs_src/body_fields/tutorial001.py!}
     ```
 
 Функция `Field` работает так же, как `Query`, `Path` и `Body`, у ее такие же параметры и т.д.
index 75e9d9064aef1f19816ee02c27b2ae85986e2694..a6f2caa267606cd3a2c60ed67e791d4eaca843ac 100644 (file)
@@ -6,16 +6,16 @@
 
 Сначала импортируйте `Cookie`:
 
-=== "Python 3.6 и выше"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3"
-    {!> ../../../docs_src/cookie_params/tutorial001.py!}
+    ```Python hl_lines="1"
+    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 и выше"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1"
-    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
+    ```Python hl_lines="3"
+    {!> ../../../docs_src/cookie_params/tutorial001.py!}
     ```
 
 ## Объявление параметров `Cookie`
 
 Первое значение - это значение по умолчанию, вы можете передать все дополнительные параметры проверки или аннотации:
 
-=== "Python 3.6 и выше"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/cookie_params/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 и выше"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/cookie_params/tutorial001.py!}
     ```
 
 !!! note "Технические детали"
index 5813272ee5882f3cfb6b70e2daafd29ace033203..f404820df0119f698434f423fc2b416f8e1d1736 100644 (file)
@@ -6,16 +6,16 @@
 
 在前面的例子中, 我们从依赖项 ("可依赖对象") 中返回了一个 `dict`:
 
-=== "Python 3.6 以及 以上"
+=== "Python 3.10+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 以及以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
     ```
 
 但是后面我们在路径操作函数的参数 `commons` 中得到了一个 `dict`。
@@ -79,46 +79,46 @@ fluffy = Cat(name="Mr Fluffy")
 
 所以,我们可以将上面的依赖项 "可依赖对象" `common_parameters` 更改为类 `CommonQueryParams`:
 
-=== "Python 3.6 以及 以上"
-
-    ```Python hl_lines="11-15"
-    {!> ../../../docs_src/dependencies/tutorial002.py!}
-    ```
-
-=== "Python 3.10 以及 以上"
+=== "Python 3.10+"
 
     ```Python hl_lines="9-13"
     {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-注意用于创建类实例的 `__init__` 方法:
-
-=== "Python 3.6 以及 以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12"
+    ```Python hl_lines="11-15"
     {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
-=== "Python 3.10 以及 以上"
+注意用于创建类实例的 `__init__` 方法:
+
+=== "Python 3.10+"
 
     ```Python hl_lines="10"
     {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-...它与我们以前的 `common_parameters` 具有相同的参数:
-
-=== "Python 3.6 以及 以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```Python hl_lines="12"
+    {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
-=== "Python 3.10 以及 以上"
+...它与我们以前的 `common_parameters` 具有相同的参数:
+
+=== "Python 3.10+"
 
     ```Python hl_lines="6"
     {!> ../../../docs_src/dependencies/tutorial001_py310.py!}
     ```
 
+=== "Python 3.6+"
+
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/dependencies/tutorial001.py!}
+    ```
+
 这些参数就是 **FastAPI** 用来 "处理" 依赖项的。
 
 在两个例子下,都有:
@@ -133,16 +133,16 @@ fluffy = Cat(name="Mr Fluffy")
 
 现在,您可以使用这个类来声明你的依赖项了。
 
-=== "Python 3.6 以及 以上"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial002.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
     ```
 
-=== "Python 3.10 以及 以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial002_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial002.py!}
     ```
 
 **FastAPI** 调用 `CommonQueryParams` 类。这将创建该类的一个 "实例",该实例将作为参数 `commons` 被传递给你的函数。
@@ -183,16 +183,16 @@ commons = Depends(CommonQueryParams)
 
 ..就像:
 
-=== "Python 3.6 以及 以上"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial003.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial003_py310.py!}
     ```
 
-=== "Python 3.10 以及 以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial003_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial003.py!}
     ```
 
 但是声明类型是被鼓励的,因为那样你的编辑器就会知道将传递什么作为参数 `commons` ,然后它可以帮助你完成代码,类型检查,等等:
@@ -227,16 +227,16 @@ commons: CommonQueryParams = Depends()
 
 同样的例子看起来像这样:
 
-=== "Python 3.6 以及 以上"
+=== "Python 3.10+"
 
-    ```Python hl_lines="19"
-    {!> ../../../docs_src/dependencies/tutorial004.py!}
+    ```Python hl_lines="17"
+    {!> ../../../docs_src/dependencies/tutorial004_py310.py!}
     ```
 
-=== "Python 3.10 以及 以上"
+=== "Python 3.6+"
 
-    ```Python hl_lines="17"
-    {!> ../../../docs_src/dependencies/tutorial004_py310.py!}
+    ```Python hl_lines="19"
+    {!> ../../../docs_src/dependencies/tutorial004.py!}
     ```
 
 ... **FastAPI** 会知道怎么处理。
index cb813940ce2525d1773f9ce671fea6726794e3f8..76ed846ce35e4ce9c252861f7aa86e0fba92086e 100644 (file)
 
 它接收一个对象,比如Pydantic模型,并会返回一个JSON兼容的版本:
 
-=== "Python 3.6 and above"
+=== "Python 3.10+"
 
-    ```Python hl_lines="5  22"
-    {!> ../../../docs_src/encoder/tutorial001.py!}
+    ```Python hl_lines="4  21"
+    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
     ```
 
-=== "Python 3.10 and above"
+=== "Python 3.6+"
 
-    ```Python hl_lines="4  21"
-    {!> ../../../docs_src/encoder/tutorial001_py310.py!}
+    ```Python hl_lines="5  22"
+    {!> ../../../docs_src/encoder/tutorial001.py!}
     ```
 
 在这个例子中,它将Pydantic模型转换为`dict`,并将`datetime`转换为`str`。
index e18d6fc9f3b6009c0171e0049272ebcf59d7890b..03474907ee94b52b2fafeb3a38d7588f4137f7c5 100644 (file)
@@ -124,16 +124,16 @@ contents = myfile.file.read()
 
 您可以通过使用标准类型注解并将 None 作为默认值的方式将一个文件参数设为可选:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9  17"
-    {!> ../../../docs_src/request_files/tutorial001_02.py!}
+    ```Python hl_lines="7  14"
+    {!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7  14"
-    {!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
+    ```Python hl_lines="9  17"
+    {!> ../../../docs_src/request_files/tutorial001_02.py!}
     ```
 
 ## 带有额外元数据的 `UploadFile`
@@ -152,16 +152,16 @@ FastAPI 支持同时上传多个文件。
 
 上传多个文件时,要声明含 `bytes` 或 `UploadFile` 的列表(`List`):
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="10  15"
-    {!> ../../../docs_src/request_files/tutorial002.py!}
+    ```Python hl_lines="8  13"
+    {!> ../../../docs_src/request_files/tutorial002_py39.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="8  13"
-    {!> ../../../docs_src/request_files/tutorial002_py39.py!}
+    ```Python hl_lines="10  15"
+    {!> ../../../docs_src/request_files/tutorial002.py!}
     ```
 
 接收的也是含 `bytes` 或 `UploadFile` 的列表(`list`)。
@@ -177,16 +177,16 @@ FastAPI 支持同时上传多个文件。
 
 和之前的方式一样, 您可以为 `File()` 设置额外参数, 即使是 `UploadFile`:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="18"
-    {!> ../../../docs_src/request_files/tutorial003.py!}
+    ```Python hl_lines="16"
+    {!> ../../../docs_src/request_files/tutorial003_py39.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="16"
-    {!> ../../../docs_src/request_files/tutorial003_py39.py!}
+    ```Python hl_lines="18"
+    {!> ../../../docs_src/request_files/tutorial003.py!}
     ```
 
 ## 小结
index 6b354c2b6d9914a10fa862e1db94527fa2eaf03f..482588f94d7ec3630b8a12670d47d0d14f61431d 100644 (file)
@@ -246,22 +246,22 @@ connect_args={"check_same_thread": False}
 
 但是为了安全起见,`password`不会出现在其他同类 Pydantic*模型*中,例如用户请求时不应该从 API 返回响应中包含它。
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.10+"
 
-    ```Python hl_lines="3  6-8  11-12  23-24  27-28"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="1  4-6  9-10  21-22  25-26"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.9+"
 
     ```Python hl_lines="3  6-8  11-12  23-24  27-28"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="1  4-6  9-10  21-22  25-26"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="3  6-8  11-12  23-24  27-28"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 #### SQLAlchemy 风格和 Pydantic 风格
@@ -290,22 +290,22 @@ name: str
 
 不仅是这些项目的 ID,还有我们在 Pydantic*模型*中定义的用于读取项目的所有数据:`Item`.
 
-=== "Python 3.6  及以上版本"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15-17  31-34"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="13-15  29-32"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9  及以上版本"
+=== "Python 3.9+"
 
     ```Python hl_lines="15-17  31-34"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10  及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13-15  29-32"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="15-17  31-34"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 !!! tip
@@ -319,22 +319,22 @@ name: str
 
 在`Config`类中,设置属性`orm_mode = True`。
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.10+"
 
-    ```Python hl_lines="15  19-20  31  36-37"
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    ```Python hl_lines="13  17-18  29  34-35"
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.9+"
 
     ```Python hl_lines="15  19-20  31  36-37"
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13  17-18  29  34-35"
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    ```Python hl_lines="15  19-20  31  36-37"
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 !!! tip
@@ -465,16 +465,16 @@ current_user.items
 
 以非常简单的方式创建数据库表:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="9"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="7"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="7"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="9"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 #### Alembic 注意
@@ -499,16 +499,16 @@ current_user.items
 
 我们的依赖项将创建一个新的 SQLAlchemy `SessionLocal`,它将在单个请求中使用,然后在请求完成后关闭它。
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="15-20"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="13-18"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="13-18"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="15-20"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 !!! info
@@ -524,16 +524,16 @@ current_user.items
 
 *这将为我们在路径操作函数*中提供更好的编辑器支持,因为编辑器将知道`db`参数的类型`Session`:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="24  32  38  47  53"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="22  30  36  45  51"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="22  30  36  45  51"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="24  32  38  47  53"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 !!! info "技术细节"
@@ -545,16 +545,16 @@ current_user.items
 
 现在,到了最后,编写标准的**FastAPI** *路径操作*代码。
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="23-28  31-34  37-42  45-49  52-55"
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    ```Python hl_lines="21-26  29-32  35-40  43-47  50-53"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="21-26  29-32  35-40  43-47  50-53"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    ```Python hl_lines="23-28  31-34  37-42  45-49  52-55"
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 我们在依赖项中的每个请求之前利用`yield`创建数据库会话,然后关闭它。
@@ -638,22 +638,22 @@ def read_user(user_id: int, db: Session = Depends(get_db)):
 
 * `sql_app/schemas.py`:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.10+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
+    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.9+"
 
     ```Python
     {!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
     ```
 
-=== "Python 3.10 及以上版本"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app_py310/schemas.py!}
+    {!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
     ```
 
 * `sql_app/crud.py`:
@@ -664,16 +664,16 @@ def read_user(user_id: int, db: Session = Depends(get_db)):
 
 * `sql_app/main.py`:
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
+    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
     ```Python
-    {!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
+    {!> ../../../docs_src/sql_databases/sql_app/main.py!}
     ```
 
 ## 执行项目
@@ -723,16 +723,16 @@ $ uvicorn sql_app.main:app --reload
 
 我们将添加中间件(只是一个函数)将为每个请求创建一个新的 SQLAlchemy`SessionLocal`,将其添加到请求中,然后在请求完成后关闭它。
 
-=== "Python 3.6 及以上版本"
+=== "Python 3.9+"
 
-    ```Python hl_lines="14-22"
-    {!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}
+    ```Python hl_lines="12-20"
+    {!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
     ```
 
-=== "Python 3.9 及以上版本"
+=== "Python 3.6+"
 
-    ```Python hl_lines="12-20"
-    {!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
+    ```Python hl_lines="14-22"
+    {!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}
     ```
 
 !!! info