Browse Source

⬆️ Drop support for Python 3.7, require Python 3.8 or above (#10442)

* 📝 Update docs, require Python 3.8+, drop 3.7

* 🔧 Update pyproject.toml, drop support for Python 3.7, require Python 3.8+

* 👷 Update CI GitHub Actions, drop support for Python 3.7, require 3.8+

* 📝 Update docs' references to Python 3.6 and 3.7, use Python 3.8
pull/9640/merge
Sebastián Ramírez 1 year ago
committed by GitHub
parent
commit
2ba7586ff3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/publish.yml
  2. 2
      .github/workflows/test.yml
  3. 6
      README.md
  4. 2
      docs/de/docs/features.md
  5. 4
      docs/en/docs/advanced/additional-status-codes.md
  6. 16
      docs/en/docs/advanced/advanced-dependencies.md
  7. 6
      docs/en/docs/advanced/generate-clients.md
  8. 12
      docs/en/docs/advanced/security/http-basic-auth.md
  9. 32
      docs/en/docs/advanced/security/oauth2-scopes.md
  10. 12
      docs/en/docs/advanced/settings.md
  11. 4
      docs/en/docs/advanced/testing-dependencies.md
  12. 6
      docs/en/docs/advanced/websockets.md
  13. 8
      docs/en/docs/how-to/separate-openapi-schemas.md
  14. 6
      docs/en/docs/index.md
  15. 24
      docs/en/docs/python-types.md
  16. 4
      docs/en/docs/tutorial/background-tasks.md
  17. 4
      docs/en/docs/tutorial/bigger-applications.md
  18. 8
      docs/en/docs/tutorial/body-fields.md
  19. 18
      docs/en/docs/tutorial/body-multiple-params.md
  20. 20
      docs/en/docs/tutorial/body-nested-models.md
  21. 8
      docs/en/docs/tutorial/body-updates.md
  22. 12
      docs/en/docs/tutorial/body.md
  23. 8
      docs/en/docs/tutorial/cookie-params.md
  24. 52
      docs/en/docs/tutorial/dependencies/classes-as-dependencies.md
  25. 16
      docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
  26. 8
      docs/en/docs/tutorial/dependencies/dependencies-with-yield.md
  27. 4
      docs/en/docs/tutorial/dependencies/global-dependencies.md
  28. 14
      docs/en/docs/tutorial/dependencies/index.md
  29. 16
      docs/en/docs/tutorial/dependencies/sub-dependencies.md
  30. 2
      docs/en/docs/tutorial/encoder.md
  31. 8
      docs/en/docs/tutorial/extra-data-types.md
  32. 10
      docs/en/docs/tutorial/extra-models.md
  33. 16
      docs/en/docs/tutorial/header-params.md
  34. 10
      docs/en/docs/tutorial/path-operation-configuration.md
  35. 26
      docs/en/docs/tutorial/path-params-numeric-validations.md
  36. 72
      docs/en/docs/tutorial/query-params-str-validations.md
  37. 8
      docs/en/docs/tutorial/query-params.md
  38. 28
      docs/en/docs/tutorial/request-files.md
  39. 8
      docs/en/docs/tutorial/request-forms-and-files.md
  40. 8
      docs/en/docs/tutorial/request-forms.md
  41. 28
      docs/en/docs/tutorial/response-model.md
  42. 18
      docs/en/docs/tutorial/schema-extra-example.md
  43. 12
      docs/en/docs/tutorial/security/first-steps.md
  44. 24
      docs/en/docs/tutorial/security/get-current-user.md
  45. 16
      docs/en/docs/tutorial/security/oauth2-jwt.md
  46. 20
      docs/en/docs/tutorial/security/simple-oauth2.md
  47. 20
      docs/en/docs/tutorial/sql-databases.md
  48. 4
      docs/en/docs/tutorial/testing.md
  49. 2
      docs/es/docs/features.md
  50. 6
      docs/es/docs/index.md
  51. 2
      docs/fr/docs/features.md
  52. 6
      docs/fr/docs/index.md
  53. 2
      docs/ja/docs/features.md
  54. 2
      docs/ja/docs/index.md
  55. 2
      docs/ko/docs/index.md
  56. 2
      docs/pl/docs/features.md
  57. 4
      docs/pl/docs/index.md
  58. 2
      docs/pt/docs/features.md
  59. 6
      docs/pt/docs/index.md
  60. 10
      docs/pt/docs/tutorial/body-multiple-params.md
  61. 2
      docs/pt/docs/tutorial/encoder.md
  62. 10
      docs/pt/docs/tutorial/extra-models.md
  63. 8
      docs/pt/docs/tutorial/header-params.md
  64. 10
      docs/pt/docs/tutorial/path-operation-configuration.md
  65. 4
      docs/pt/docs/tutorial/path-params-numeric-validations.md
  66. 8
      docs/pt/docs/tutorial/query-params.md
  67. 2
      docs/ru/docs/features.md
  68. 6
      docs/ru/docs/index.md
  69. 2
      docs/ru/docs/tutorial/background-tasks.md
  70. 4
      docs/ru/docs/tutorial/body-fields.md
  71. 18
      docs/ru/docs/tutorial/body-multiple-params.md
  72. 20
      docs/ru/docs/tutorial/body-nested-models.md
  73. 4
      docs/ru/docs/tutorial/cookie-params.md
  74. 4
      docs/ru/docs/tutorial/dependencies/global-dependencies.md
  75. 4
      docs/ru/docs/tutorial/extra-data-types.md
  76. 10
      docs/ru/docs/tutorial/extra-models.md
  77. 16
      docs/ru/docs/tutorial/header-params.md
  78. 10
      docs/ru/docs/tutorial/path-operation-configuration.md
  79. 26
      docs/ru/docs/tutorial/path-params-numeric-validations.md
  80. 72
      docs/ru/docs/tutorial/query-params-str-validations.md
  81. 8
      docs/ru/docs/tutorial/query-params.md
  82. 8
      docs/ru/docs/tutorial/request-forms.md
  83. 28
      docs/ru/docs/tutorial/response-model.md
  84. 12
      docs/ru/docs/tutorial/schema-extra-example.md
  85. 4
      docs/ru/docs/tutorial/testing.md
  86. 2
      docs/tr/docs/features.md
  87. 6
      docs/tr/docs/index.md
  88. 22
      docs/uk/docs/python-types.md
  89. 12
      docs/uk/docs/tutorial/body.md
  90. 8
      docs/uk/docs/tutorial/cookie-params.md
  91. 2
      docs/uk/docs/tutorial/encoder.md
  92. 8
      docs/uk/docs/tutorial/extra-data-types.md
  93. 2
      docs/vi/docs/features.md
  94. 6
      docs/vi/docs/index.md
  95. 18
      docs/vi/docs/python-types.md
  96. 6
      docs/yo/docs/index.md
  97. 6
      docs/zh/docs/advanced/generate-clients.md
  98. 12
      docs/zh/docs/advanced/settings.md
  99. 6
      docs/zh/docs/advanced/websockets.md
  100. 6
      docs/zh/docs/index.md

2
.github/workflows/publish.yml

@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.10"
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
cache-dependency-path: pyproject.toml

2
.github/workflows/test.yml

@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
pydantic-version: ["pydantic-v1", "pydantic-v2"]
fail-fast: false
steps:

6
README.md

@ -27,7 +27,7 @@
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.
The key features are:
@ -120,7 +120,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
## Requirements
Python 3.7+
Python 3.8+
FastAPI stands on the shoulders of giants:
@ -336,7 +336,7 @@ You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python 3.7+**.
Just standard **Python 3.8+**.
For example, for an `int`:

2
docs/de/docs/features.md

@ -25,7 +25,7 @@ Mit einer interaktiven API-Dokumentation und explorativen webbasierten Benutzers
### Nur modernes Python
Alles basiert auf **Python 3.6 Typ**-Deklarationen (dank Pydantic). Es muss keine neue Syntax gelernt werden, nur standardisiertes modernes Python.
Alles basiert auf **Python 3.8 Typ**-Deklarationen (dank Pydantic). Es muss keine neue Syntax gelernt werden, nur standardisiertes modernes Python.

4
docs/en/docs/advanced/additional-status-codes.md

@ -26,7 +26,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 26"
{!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
@ -41,7 +41,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/advanced/advanced-dependencies.md

@ -24,13 +24,13 @@ To do that, we declare a method `__call__`:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -51,13 +51,13 @@ And now, we can use `__init__` to declare the parameters of the instance that we
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -78,13 +78,13 @@ We could create an instance of this class with:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -113,13 +113,13 @@ checker(q="somequery")
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

6
docs/en/docs/advanced/generate-clients.md

@ -35,7 +35,7 @@ Let's start with a simple FastAPI application:
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
@ -147,7 +147,7 @@ For example, you could have a section for **items** and another section for **us
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
@ -204,7 +204,7 @@ You can then pass that custom function to **FastAPI** as the `generate_unique_id
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}

12
docs/en/docs/advanced/security/http-basic-auth.md

@ -26,13 +26,13 @@ Then, when you type that username and password, the browser sends them in the he
{!> ../../../docs_src/security/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 7 11"
{!> ../../../docs_src/security/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -65,13 +65,13 @@ Then we can use `secrets.compare_digest()` to ensure that `credentials.username`
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 12-24"
{!> ../../../docs_src/security/tutorial007_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -148,13 +148,13 @@ After detecting that the credentials are incorrect, return an `HTTPException` wi
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="26-30"
{!> ../../../docs_src/security/tutorial007_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

32
docs/en/docs/advanced/security/oauth2-scopes.md

@ -68,7 +68,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 4 8 12 47 65 106 108-116 122-125 129-135 140 156"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -92,7 +92,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -121,7 +121,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="63-66"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -146,7 +146,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -188,7 +188,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="156"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -212,7 +212,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -254,7 +254,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 140 171"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -278,7 +278,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -320,7 +320,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 106"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -344,7 +344,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -377,7 +377,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="106 108-116"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -401,7 +401,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -436,7 +436,7 @@ We also verify that we have a user with that username, and if not, we raise that
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="47 117-128"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -460,7 +460,7 @@ 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.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -487,7 +487,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="129-135"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -511,7 +511,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

12
docs/en/docs/advanced/settings.md

@ -260,13 +260,13 @@ Now we create a dependency that returns a new `config.Settings()`.
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="6 12-13"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -288,13 +288,13 @@ And then we can require it from the *path operation function* as a dependency an
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 19-21"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -396,13 +396,13 @@ But as we are using the `@lru_cache()` decorator on top, the `Settings` object w
{!> ../../../docs_src/settings/app03_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 11"
{!> ../../../docs_src/settings/app03_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/advanced/testing-dependencies.md

@ -40,7 +40,7 @@ And then **FastAPI** will call that override instead of the original dependency.
{!> ../../../docs_src/dependency_testing/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="29-30 33"
{!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
@ -55,7 +55,7 @@ And then **FastAPI** will call that override instead of the original dependency.
{!> ../../../docs_src/dependency_testing/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

6
docs/en/docs/advanced/websockets.md

@ -124,7 +124,7 @@ They work the same way as for other FastAPI endpoints/*path operations*:
{!> ../../../docs_src/websockets/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="69-70 83"
{!> ../../../docs_src/websockets/tutorial002_an.py!}
@ -139,7 +139,7 @@ They work the same way as for other FastAPI endpoints/*path operations*:
{!> ../../../docs_src/websockets/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,7 +191,7 @@ When a WebSocket connection is closed, the `await websocket.receive_text()` will
{!> ../../../docs_src/websockets/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="81-83"
{!> ../../../docs_src/websockets/tutorial003.py!}

8
docs/en/docs/how-to/separate-openapi-schemas.md

@ -44,7 +44,7 @@ Let's say you have a Pydantic model with default values, like this one:
</details>
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-9]!}
@ -99,7 +99,7 @@ If you use this model as an input like here:
</details>
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="16"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-17]!}
@ -142,7 +142,7 @@ But if you use the same model as an output, like here:
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
```
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py!}
@ -214,7 +214,7 @@ In that case, you can disable this feature in **FastAPI**, with the parameter `s
{!> ../../../docs_src/separate_openapi_schemas/tutorial002_py39.py!}
```
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/separate_openapi_schemas/tutorial002.py!}

6
docs/en/docs/index.md

@ -27,7 +27,7 @@
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.
The key features are:
@ -115,7 +115,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
## Requirements
Python 3.7+
Python 3.8+
FastAPI stands on the shoulders of giants:
@ -331,7 +331,7 @@ You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python 3.7+**.
Just standard **Python 3.8+**.
For example, for an `int`:

24
docs/en/docs/python-types.md

@ -182,7 +182,7 @@ For example, let's define a variable to be a `list` of `str`.
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
From `typing`, import `List` (with a capital `L`):
@ -230,7 +230,7 @@ You would do the same to declare `tuple`s and `set`s:
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
@ -255,7 +255,7 @@ The second type parameter is for the values of the `dict`:
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
@ -281,7 +281,7 @@ In Python 3.10 there's also a **new syntax** where you can put the possible type
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
@ -311,13 +311,13 @@ This also means that in Python 3.10, you can use `Something | None`:
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
```
=== "Python 3.6+ alternative"
=== "Python 3.8+ alternative"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
@ -375,10 +375,10 @@ These types that take type parameters in square brackets are called **Generic ty
* `set`
* `dict`
And the same as with Python 3.6, from the `typing` module:
And the same as with Python 3.8, from the `typing` module:
* `Union`
* `Optional` (the same as with Python 3.6)
* `Optional` (the same as with Python 3.8)
* ...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, that's a lot better and simpler.
@ -392,13 +392,13 @@ These types that take type parameters in square brackets are called **Generic ty
* `set`
* `dict`
And the same as with Python 3.6, from the `typing` module:
And the same as with Python 3.8, from the `typing` module:
* `Union`
* `Optional`
* ...and others.
=== "Python 3.6+"
=== "Python 3.8+"
* `List`
* `Tuple`
@ -458,7 +458,7 @@ An example from the official Pydantic docs:
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
@ -486,7 +486,7 @@ Python also has a feature that allows putting **additional metadata** in these t
{!> ../../../docs_src/python_types/tutorial013_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
In versions below Python 3.9, you import `Annotated` from `typing_extensions`.

4
docs/en/docs/tutorial/background-tasks.md

@ -69,7 +69,7 @@ Using `BackgroundTasks` also works with the dependency injection system, you can
{!> ../../../docs_src/background_tasks/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14 16 23 26"
{!> ../../../docs_src/background_tasks/tutorial002_an.py!}
@ -84,7 +84,7 @@ Using `BackgroundTasks` also works with the dependency injection system, you can
{!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/tutorial/bigger-applications.md

@ -118,13 +118,13 @@ We will now use a simple dependency to read a custom `X-Token` header:
{!> ../../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 5-7"
{!> ../../../docs_src/bigger_applications/app_an/dependencies.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/body-fields.md

@ -18,7 +18,7 @@ First, you have to import it:
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
@ -33,7 +33,7 @@ First, you have to import it:
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -61,7 +61,7 @@ You can then use `Field` with model attributes:
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12-15"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
@ -76,7 +76,7 @@ You can then use `Field` with model attributes:
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

18
docs/en/docs/tutorial/body-multiple-params.md

@ -20,7 +20,7 @@ And you can also declare body parameters as optional, by setting the default to
{!> ../../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
@ -35,7 +35,7 @@ And you can also declare body parameters as optional, by setting the default to
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -68,7 +68,7 @@ But you can also declare multiple body parameters, e.g. `item` and `user`:
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
@ -123,7 +123,7 @@ But you can instruct **FastAPI** to treat it as another body key using `Body`:
{!> ../../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
@ -138,7 +138,7 @@ But you can instruct **FastAPI** to treat it as another body key using `Body`:
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -197,7 +197,7 @@ For example:
{!> ../../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="28"
{!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
@ -212,7 +212,7 @@ For example:
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -250,7 +250,7 @@ as in:
{!> ../../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
@ -265,7 +265,7 @@ as in:
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

20
docs/en/docs/tutorial/body-nested-models.md

@ -12,7 +12,7 @@ You can define an attribute to be a subtype. For example, a Python `list`:
{!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial001.py!}
@ -73,7 +73,7 @@ So, in our example, we can make `tags` be specifically a "list of strings":
{!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
@ -99,7 +99,7 @@ Then we can declare `tags` as a set of strings:
{!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14"
{!> ../../../docs_src/body_nested_models/tutorial003.py!}
@ -137,7 +137,7 @@ For example, we can define an `Image` model:
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -159,7 +159,7 @@ And then we can use it as the type of an attribute:
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -208,7 +208,7 @@ For example, as in the `Image` model we have a `url` field, we can declare it to
{!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005.py!}
@ -232,7 +232,7 @@ You can also use Pydantic models as subtypes of `list`, `set`, etc:
{!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006.py!}
@ -283,7 +283,7 @@ You can define arbitrarily deeply nested models:
{!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007.py!}
@ -314,7 +314,7 @@ as in:
{!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/body_nested_models/tutorial008.py!}
@ -354,7 +354,7 @@ In this case, you would accept any `dict` as long as it has `int` keys with `flo
{!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/body_nested_models/tutorial009.py!}

8
docs/en/docs/tutorial/body-updates.md

@ -18,7 +18,7 @@ You can use the `jsonable_encoder` to convert the input data to data that can be
{!> ../../../docs_src/body_updates/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001.py!}
@ -79,7 +79,7 @@ Then you can use this to generate a `dict` with only the data that was set (sent
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002.py!}
@ -103,7 +103,7 @@ Like `stored_item_model.copy(update=update_data)`:
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002.py!}
@ -136,7 +136,7 @@ In summary, to apply partial updates you would:
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002.py!}

12
docs/en/docs/tutorial/body.md

@ -25,7 +25,7 @@ First, you need to import `BaseModel` from `pydantic`:
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
@ -43,7 +43,7 @@ Use standard Python types for all the attributes:
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
@ -81,7 +81,7 @@ To add it to your *path operation*, declare it the same way you declared path an
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
@ -155,7 +155,7 @@ Inside of the function, you can access all the attributes of the model object di
{!> ../../../docs_src/body/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
@ -173,7 +173,7 @@ You can declare path parameters and request body at the same time.
{!> ../../../docs_src/body/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
@ -191,7 +191,7 @@ You can also declare **body**, **path** and **query** parameters, all at the sam
{!> ../../../docs_src/body/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}

8
docs/en/docs/tutorial/cookie-params.md

@ -18,7 +18,7 @@ First import `Cookie`:
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -33,7 +33,7 @@ First import `Cookie`:
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -60,7 +60,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -75,7 +75,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

52
docs/en/docs/tutorial/dependencies/classes-as-dependencies.md

@ -18,7 +18,7 @@ In the previous example, we were returning a `dict` from our dependency ("depend
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -33,7 +33,7 @@ In the previous example, we were returning a `dict` from our dependency ("depend
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -115,7 +115,7 @@ Then, we can change the dependency "dependable" `common_parameters` from above t
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12-16"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -130,7 +130,7 @@ Then, we can change the dependency "dependable" `common_parameters` from above t
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -153,7 +153,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -168,7 +168,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,7 +191,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -206,7 +206,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -241,7 +241,7 @@ Now you can declare your dependency using this class.
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -256,7 +256,7 @@ Now you can declare your dependency using this class.
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -271,7 +271,7 @@ Now you can declare your dependency using this class.
Notice how we write `CommonQueryParams` twice in the above code:
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -280,7 +280,7 @@ Notice how we write `CommonQueryParams` twice in the above code:
commons: CommonQueryParams = Depends(CommonQueryParams)
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
@ -300,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+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, ...
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -319,13 +319,13 @@ In this case, the first `CommonQueryParams`, in:
You could actually write just:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[Any, Depends(CommonQueryParams)]
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -348,7 +348,7 @@ You could actually write just:
{!> ../../../docs_src/dependencies/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial003_an.py!}
@ -363,7 +363,7 @@ You could actually write just:
{!> ../../../docs_src/dependencies/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -380,7 +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+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -389,7 +389,7 @@ But you see that we are having some code repetition here, writing `CommonQueryPa
commons: CommonQueryParams = Depends(CommonQueryParams)
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
@ -401,13 +401,13 @@ For those specific cases, you can do the following:
Instead of writing:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -418,13 +418,13 @@ Instead of writing:
...you write:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends()]
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -449,7 +449,7 @@ The same example would then look like:
{!> ../../../docs_src/dependencies/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial004_an.py!}
@ -464,7 +464,7 @@ The same example would then look like:
{!> ../../../docs_src/dependencies/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md

@ -20,13 +20,13 @@ It should be a `list` of `Depends()`:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -63,13 +63,13 @@ They can declare request requirements (like headers) or other sub-dependencies:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7 12"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -88,13 +88,13 @@ These dependencies can `raise` exceptions, the same as normal dependencies:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 14"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -115,13 +115,13 @@ So, you can re-use a normal dependency (that returns a value) you already use so
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10 15"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/dependencies/dependencies-with-yield.md

@ -72,13 +72,13 @@ For example, `dependency_c` can have a dependency on `dependency_b`, and `depend
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 13 21"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -99,13 +99,13 @@ And, in turn, `dependency_b` needs the value from `dependency_a` (here named `de
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17-18 25-26"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/tutorial/dependencies/global-dependencies.md

@ -12,13 +12,13 @@ In that case, they will be applied to all the *path operations* in the applicati
{!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial012_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

14
docs/en/docs/tutorial/dependencies/index.md

@ -43,7 +43,7 @@ It is just a function that can take all the same parameters that a *path operati
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -58,7 +58,7 @@ It is just a function that can take all the same parameters that a *path operati
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -106,7 +106,7 @@ And then it just returns a `dict` containing those values.
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -121,7 +121,7 @@ And then it just returns a `dict` containing those values.
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -146,7 +146,7 @@ The same way you use `Body`, `Query`, etc. with your *path operation function* p
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="16 21"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -161,7 +161,7 @@ The same way you use `Body`, `Query`, etc. with your *path operation function* p
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -231,7 +231,7 @@ But because we are using `Annotated`, we can store that `Annotated` value in a v
{!> ../../../docs_src/dependencies/tutorial001_02_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15 19 24"
{!> ../../../docs_src/dependencies/tutorial001_02_an.py!}

16
docs/en/docs/tutorial/dependencies/sub-dependencies.md

@ -22,7 +22,7 @@ You could create a first dependency ("dependable") like:
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-10"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -37,7 +37,7 @@ You could create a first dependency ("dependable") like:
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -66,7 +66,7 @@ Then you can create another dependency function (a "dependable") that at the sam
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -81,7 +81,7 @@ Then you can create another dependency function (a "dependable") that at the sam
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -113,7 +113,7 @@ Then we can use the dependency with:
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -128,7 +128,7 @@ Then we can use the dependency with:
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -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+"
=== "Python 3.8+"
```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+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

2
docs/en/docs/tutorial/encoder.md

@ -26,7 +26,7 @@ It receives an object, like a Pydantic model, and returns a JSON compatible vers
{!> ../../../docs_src/encoder/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 22"
{!> ../../../docs_src/encoder/tutorial001.py!}

8
docs/en/docs/tutorial/extra-data-types.md

@ -67,7 +67,7 @@ Here's an example *path operation* with parameters using some of the above types
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 3 13-17"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -82,7 +82,7 @@ Here's an example *path operation* with parameters using some of the above types
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -105,7 +105,7 @@ Note that the parameters inside the function have their natural data type, and y
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-20"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -120,7 +120,7 @@ Note that the parameters inside the function have their natural data type, and y
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

10
docs/en/docs/tutorial/extra-models.md

@ -23,7 +23,7 @@ Here's a general idea of how the models could look like with their password fiel
{!> ../../../docs_src/extra_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../../docs_src/extra_models/tutorial001.py!}
@ -164,7 +164,7 @@ That way, we can declare just the differences between the models (with plaintext
{!> ../../../docs_src/extra_models/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../../docs_src/extra_models/tutorial002.py!}
@ -187,7 +187,7 @@ To do that, use the standard Python type hint <a href="https://docs.python.org/3
{!> ../../../docs_src/extra_models/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003.py!}
@ -219,7 +219,7 @@ For that, use the standard Python `typing.List` (or just `list` in Python 3.9 an
{!> ../../../docs_src/extra_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 20"
{!> ../../../docs_src/extra_models/tutorial004.py!}
@ -239,7 +239,7 @@ In this case, you can use `typing.Dict` (or just `dict` in Python 3.9 and above)
{!> ../../../docs_src/extra_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 8"
{!> ../../../docs_src/extra_models/tutorial005.py!}

16
docs/en/docs/tutorial/header-params.md

@ -18,7 +18,7 @@ First import `Header`:
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -33,7 +33,7 @@ First import `Header`:
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -60,7 +60,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -75,7 +75,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -120,7 +120,7 @@ If for some reason you need to disable automatic conversion of underscores to hy
{!> ../../../docs_src/header_params/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/header_params/tutorial002_an.py!}
@ -135,7 +135,7 @@ If for some reason you need to disable automatic conversion of underscores to hy
{!> ../../../docs_src/header_params/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -169,7 +169,7 @@ For example, to declare a header of `X-Token` that can appear more than once, yo
{!> ../../../docs_src/header_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial003_an.py!}
@ -193,7 +193,7 @@ 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.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

10
docs/en/docs/tutorial/path-operation-configuration.md

@ -25,7 +25,7 @@ But if you don't remember what each number code is for, you can use the shortcut
{!> ../../../docs_src/path_operation_configuration/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
@ -54,7 +54,7 @@ You can add tags to your *path operation*, pass the parameter `tags` with a `lis
{!> ../../../docs_src/path_operation_configuration/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
@ -92,7 +92,7 @@ You can add a `summary` and `description`:
{!> ../../../docs_src/path_operation_configuration/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
@ -116,7 +116,7 @@ You can write <a href="https://en.wikipedia.org/wiki/Markdown" class="external-l
{!> ../../../docs_src/path_operation_configuration/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
@ -142,7 +142,7 @@ You can specify the response description with the parameter `response_descriptio
{!> ../../../docs_src/path_operation_configuration/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005.py!}

26
docs/en/docs/tutorial/path-params-numeric-validations.md

@ -18,7 +18,7 @@ First, import `Path` from `fastapi`, and import `Annotated`:
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3-4"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -33,7 +33,7 @@ First, import `Path` from `fastapi`, and import `Annotated`:
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -67,7 +67,7 @@ For example, to declare a `title` metadata value for the path parameter `item_id
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -82,7 +82,7 @@ For example, to declare a `title` metadata value for the path parameter `item_id
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -117,7 +117,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.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -134,7 +134,7 @@ But have in mind that if you use `Annotated`, you won't have this problem, it wo
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
@ -174,7 +174,7 @@ Have in mind that if you use `Annotated`, as you are not using function paramete
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
@ -192,13 +192,13 @@ Here, with `ge=1`, `item_id` will need to be an integer number "`g`reater than o
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -220,13 +220,13 @@ The same applies for:
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -251,13 +251,13 @@ And the same for <abbr title="less than"><code>lt</code></abbr>.
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

72
docs/en/docs/tutorial/query-params-str-validations.md

@ -10,7 +10,7 @@ Let's take this application as example:
{!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
@ -42,7 +42,7 @@ To achieve that, first import:
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
In versions of Python below Python 3.9 you import `Annotated` from `typing_extensions`.
@ -73,7 +73,7 @@ We had this type annotation:
q: str | None = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Union[str, None] = None
@ -87,7 +87,7 @@ What we will do is wrap that with `Annotated`, so it becomes:
q: Annotated[str | None] = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Annotated[Union[str, None]] = None
@ -107,7 +107,7 @@ Now that we have this `Annotated` where we can put more metadata, add `Query` to
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
@ -138,7 +138,7 @@ This is how you would use `Query()` as the default value of your function parame
{!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
@ -251,7 +251,7 @@ You can also add a parameter `min_length`:
{!> ../../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
@ -266,7 +266,7 @@ You can also add a parameter `min_length`:
{!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -291,7 +291,7 @@ You can define a <abbr title="A regular expression, regex or regexp is a sequenc
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
@ -306,7 +306,7 @@ You can define a <abbr title="A regular expression, regex or regexp is a sequenc
{!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -351,13 +351,13 @@ Let's say that you want to declare the `q` query parameter to have a `min_length
{!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -405,13 +405,13 @@ So, when you need to declare a value as required while using `Query`, you can si
{!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -435,13 +435,13 @@ There's an alternative way to explicitly declare that a value is required. You c
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -475,7 +475,7 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
@ -490,7 +490,7 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
{!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -512,13 +512,13 @@ If you feel uncomfortable using `...`, you can also import and use `Required` fr
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 9"
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -548,7 +548,7 @@ For example, to declare a query parameter `q` that can appear multiple times in
{!> ../../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
@ -572,7 +572,7 @@ 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.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -617,7 +617,7 @@ And you can also define a default `list` of values if none are provided:
{!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
@ -632,7 +632,7 @@ And you can also define a default `list` of values if none are provided:
{!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -668,13 +668,13 @@ You can also use `list` directly instead of `List[str]` (or `list[str]` in Pytho
{!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -713,7 +713,7 @@ You can add a `title`:
{!> ../../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
@ -728,7 +728,7 @@ You can add a `title`:
{!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -751,7 +751,7 @@ And a `description`:
{!> ../../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
@ -766,7 +766,7 @@ And a `description`:
{!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -805,7 +805,7 @@ Then you can declare an `alias`, and that alias is what will be used to find the
{!> ../../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
@ -820,7 +820,7 @@ Then you can declare an `alias`, and that alias is what will be used to find the
{!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -849,7 +849,7 @@ Then pass the parameter `deprecated=True` to `Query`:
{!> ../../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
@ -864,7 +864,7 @@ Then pass the parameter `deprecated=True` to `Query`:
{!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -893,7 +893,7 @@ To exclude a query parameter from the generated OpenAPI schema (and thus, from t
{!> ../../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
@ -908,7 +908,7 @@ To exclude a query parameter from the generated OpenAPI schema (and thus, from t
{!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/query-params.md

@ -69,7 +69,7 @@ The same way, you can declare optional query parameters, by setting their defaul
{!> ../../../docs_src/query_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial002.py!}
@ -90,7 +90,7 @@ You can also declare `bool` types, and they will be converted:
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial003.py!}
@ -143,7 +143,7 @@ They will be detected by name:
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 10"
{!> ../../../docs_src/query_params/tutorial004.py!}
@ -209,7 +209,7 @@ And of course, you can define some parameters as required, some as having a defa
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params/tutorial006.py!}

28
docs/en/docs/tutorial/request-files.md

@ -19,13 +19,13 @@ Import `File` and `UploadFile` from `fastapi`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -44,13 +44,13 @@ Create file parameters the same way you would for `Body` or `Form`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -85,13 +85,13 @@ Define a file parameter with a type of `UploadFile`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="13"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -181,7 +181,7 @@ You can make a file optional by using standard type annotations and setting a de
{!> ../../../docs_src/request_files/tutorial001_02_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10 18"
{!> ../../../docs_src/request_files/tutorial001_02_an.py!}
@ -196,7 +196,7 @@ You can make a file optional by using standard type annotations and setting a de
{!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -215,13 +215,13 @@ You can also use `File()` with `UploadFile`, for example, to set additional meta
{!> ../../../docs_src/request_files/tutorial001_03_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 14"
{!> ../../../docs_src/request_files/tutorial001_03_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -244,7 +244,7 @@ To use that, declare a list of `bytes` or `UploadFile`:
{!> ../../../docs_src/request_files/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11 16"
{!> ../../../docs_src/request_files/tutorial002_an.py!}
@ -259,7 +259,7 @@ To use that, declare a list of `bytes` or `UploadFile`:
{!> ../../../docs_src/request_files/tutorial002_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -285,7 +285,7 @@ And the same way as before, you can use `File()` to set additional parameters, e
{!> ../../../docs_src/request_files/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12 19-21"
{!> ../../../docs_src/request_files/tutorial003_an.py!}
@ -300,7 +300,7 @@ And the same way as before, you can use `File()` to set additional parameters, e
{!> ../../../docs_src/request_files/tutorial003_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/request-forms-and-files.md

@ -15,13 +15,13 @@ You can define files and form fields at the same time using `File` and `Form`.
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -40,13 +40,13 @@ Create file and form parameters the same way you would for `Body` or `Query`:
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/request-forms.md

@ -17,13 +17,13 @@ Import `Form` from `fastapi`:
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -42,13 +42,13 @@ Create form parameters the same way you would for `Body` or `Query`:
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

28
docs/en/docs/tutorial/response-model.md

@ -16,7 +16,7 @@ You can use **type annotations** the same way you would for input data in functi
{!> ../../../docs_src/response_model/tutorial001_01_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18 23"
{!> ../../../docs_src/response_model/tutorial001_01.py!}
@ -65,7 +65,7 @@ You can use the `response_model` parameter in any of the *path operations*:
{!> ../../../docs_src/response_model/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001.py!}
@ -101,7 +101,7 @@ Here we are declaring a `UserIn` model, it will contain a plaintext password:
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -121,7 +121,7 @@ And we are using this model to declare our input and the same model to declare o
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -146,7 +146,7 @@ We can instead create an input model with the plaintext password and an output m
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -160,7 +160,7 @@ Here, even though our *path operation function* is returning the same input user
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -174,7 +174,7 @@ Here, even though our *path operation function* is returning the same input user
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -208,7 +208,7 @@ And in those cases, we can use classes and inheritance to take advantage of func
{!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-13 15-16 20"
{!> ../../../docs_src/response_model/tutorial003_01.py!}
@ -284,7 +284,7 @@ The same would happen if you had something like a <abbr title='A union between m
{!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/response_model/tutorial003_04.py!}
@ -306,7 +306,7 @@ In this case, you can disable the response model generation by setting `response
{!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/response_model/tutorial003_05.py!}
@ -330,7 +330,7 @@ Your response model could have default values, like:
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11 13-14"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -360,7 +360,7 @@ You can set the *path operation decorator* parameter `response_model_exclude_uns
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -447,7 +447,7 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
{!> ../../../docs_src/response_model/tutorial005_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial005.py!}
@ -468,7 +468,7 @@ If you forget to use a `set` and use a `list` or `tuple` instead, FastAPI will s
{!> ../../../docs_src/response_model/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial006.py!}

18
docs/en/docs/tutorial/schema-extra-example.md

@ -20,13 +20,13 @@ You can declare `examples` for a Pydantic model that will be added to the genera
{!> ../../../docs_src/schema_extra_example/tutorial001_py310_pv1.py!}
```
=== "Python 3.6+ Pydantic v2"
=== "Python 3.8+ Pydantic v2"
```Python hl_lines="15-26"
{!> ../../../docs_src/schema_extra_example/tutorial001.py!}
```
=== "Python 3.6+ Pydantic v1"
=== "Python 3.8+ Pydantic v1"
```Python hl_lines="15-25"
{!> ../../../docs_src/schema_extra_example/tutorial001_pv1.py!}
@ -68,7 +68,7 @@ When using `Field()` with Pydantic models, you can also declare additional `exam
{!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10-13"
{!> ../../../docs_src/schema_extra_example/tutorial002.py!}
@ -104,7 +104,7 @@ Here we pass `examples` containing one example of the data expected in `Body()`:
{!> ../../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23-30"
{!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
@ -119,7 +119,7 @@ Here we pass `examples` containing one example of the data expected in `Body()`:
{!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -150,7 +150,7 @@ You can of course also pass multiple `examples`:
{!> ../../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24-39"
{!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
@ -165,7 +165,7 @@ You can of course also pass multiple `examples`:
{!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -225,7 +225,7 @@ You can use it like this:
{!> ../../../docs_src/schema_extra_example/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24-50"
{!> ../../../docs_src/schema_extra_example/tutorial005_an.py!}
@ -240,7 +240,7 @@ You can use it like this:
{!> ../../../docs_src/schema_extra_example/tutorial005_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

12
docs/en/docs/tutorial/security/first-steps.md

@ -26,13 +26,13 @@ Copy the example in a file `main.py`:
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -140,13 +140,13 @@ When we create an instance of the `OAuth2PasswordBearer` class we pass in the `t
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,13 +191,13 @@ Now you can pass that `oauth2_scheme` in a dependency with `Depends`.
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

24
docs/en/docs/tutorial/security/get-current-user.md

@ -8,13 +8,13 @@ In the previous chapter the security system (which is based on the dependency in
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -45,7 +45,7 @@ The same way we use Pydantic to declare bodies, we can use it anywhere else:
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 13-17"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -60,7 +60,7 @@ The same way we use Pydantic to declare bodies, we can use it anywhere else:
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -91,7 +91,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="26"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -106,7 +106,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -131,7 +131,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20-23 27-28"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -146,7 +146,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -171,7 +171,7 @@ So now we can use the same `Depends` with our `get_current_user` in the *path op
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="32"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -186,7 +186,7 @@ So now we can use the same `Depends` with our `get_current_user` in the *path op
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -253,7 +253,7 @@ And all these thousands of *path operations* can be as small as 3 lines:
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31-33"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -268,7 +268,7 @@ And all these thousands of *path operations* can be as small as 3 lines:
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/tutorial/security/oauth2-jwt.md

@ -121,7 +121,7 @@ And another one to authenticate and return a user.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7 49 56-57 60-61 70-76"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -136,7 +136,7 @@ And another one to authenticate and return a user.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -188,7 +188,7 @@ Create a utility function to generate a new access token.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="6 13-15 29-31 79-87"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -203,7 +203,7 @@ Create a utility function to generate a new access token.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -232,7 +232,7 @@ If the token is invalid, return an HTTP error right away.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="90-107"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -247,7 +247,7 @@ If the token is invalid, return an HTTP error right away.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -274,7 +274,7 @@ Create a real JWT access token and return it
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="118-133"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -289,7 +289,7 @@ Create a real JWT access token and return it
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

20
docs/en/docs/tutorial/security/simple-oauth2.md

@ -61,7 +61,7 @@ First, import `OAuth2PasswordRequestForm`, and use it as a dependency with `Depe
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 79"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -76,7 +76,7 @@ First, import `OAuth2PasswordRequestForm`, and use it as a dependency with `Depe
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -134,7 +134,7 @@ For the error, we use the exception `HTTPException`:
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 80-82"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -149,7 +149,7 @@ For the error, we use the exception `HTTPException`:
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -194,7 +194,7 @@ So, the thief won't be able to try to use those same passwords in another system
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="83-86"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -209,7 +209,7 @@ So, the thief won't be able to try to use those same passwords in another system
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -264,7 +264,7 @@ For this simple example, we are going to just be completely insecure and return
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="88"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -279,7 +279,7 @@ For this simple example, we are going to just be completely insecure and return
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -321,7 +321,7 @@ So, in our endpoint, we will only get a user if the user exists, was correctly a
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="59-67 70-75 95"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -336,7 +336,7 @@ So, in our endpoint, we will only get a user if the user exists, was correctly a
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

20
docs/en/docs/tutorial/sql-databases.md

@ -281,7 +281,7 @@ But for security, the `password` won't be in other Pydantic *models*, for exampl
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 6-8 11-12 23-24 27-28"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -325,7 +325,7 @@ Not only the IDs of those items, but all the data that we defined in the Pydanti
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15-17 31-34"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -354,7 +354,7 @@ In the `Config` class, set the attribute `orm_mode = True`.
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15 19-20 31 36-37"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -494,7 +494,7 @@ In a very simplistic way create the database tables:
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -528,7 +528,7 @@ Our dependency will create a new SQLAlchemy `SessionLocal` that will be used in
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15-20"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -553,7 +553,7 @@ This will then give us better editor support inside the *path operation function
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24 32 38 47 53"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -574,7 +574,7 @@ Now, finally, here's the standard **FastAPI** *path operations* code.
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23-28 31-34 37-42 45-49 52-55"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -673,7 +673,7 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -693,7 +693,7 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -752,7 +752,7 @@ The middleware we'll add (just a function) will create a new SQLAlchemy `Session
{!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14-22"
{!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}

4
docs/en/docs/tutorial/testing.md

@ -122,7 +122,7 @@ Both *path operations* require an `X-Token` header.
{!> ../../../docs_src/app_testing/app_b_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/app_testing/app_b_an/main.py!}
@ -137,7 +137,7 @@ Both *path operations* require an `X-Token` header.
{!> ../../../docs_src/app_testing/app_b_py310/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

2
docs/es/docs/features.md

@ -25,7 +25,7 @@ Documentación interactiva de la API e interfaces web de exploración. Hay múlt
### Simplemente Python moderno
Todo está basado en las declaraciones de tipo de **Python 3.6** estándar (gracias a Pydantic). No necesitas aprender una sintáxis nueva, solo Python moderno.
Todo está basado en las declaraciones de tipo de **Python 3.8** estándar (gracias a Pydantic). No necesitas aprender una sintáxis nueva, solo Python moderno.
Si necesitas un repaso de 2 minutos de cómo usar los tipos de Python (así no uses FastAPI) prueba el tutorial corto: [Python Types](python-types.md){.internal-link target=_blank}.

6
docs/es/docs/index.md

@ -23,7 +23,7 @@
**Código Fuente**: <a href="https://github.com/tiangolo/fastapi" target="_blank">https://github.com/tiangolo/fastapi</a>
---
FastAPI es un web framework moderno y rápido (de alto rendimiento) para construir APIs con Python 3.6+ basado en las anotaciones de tipos estándar de Python.
FastAPI es un web framework moderno y rápido (de alto rendimiento) para construir APIs con Python 3.8+ basado en las anotaciones de tipos estándar de Python.
Sus características principales son:
@ -106,7 +106,7 @@ Si estás construyendo un app de <abbr title="Interfaz de línea de comandos en
## Requisitos
Python 3.7+
Python 3.8+
FastAPI está sobre los hombros de gigantes:
@ -319,7 +319,7 @@ Lo haces con tipos modernos estándar de Python.
No tienes que aprender una sintáxis nueva, los métodos o clases de una library específica, etc.
Solo **Python 3.6+** estándar.
Solo **Python 3.8+** estándar.
Por ejemplo, para un `int`:

2
docs/fr/docs/features.md

@ -25,7 +25,7 @@ Documentation d'API interactive et interface web d'exploration. Comme le framewo
### Faite en python moderne
Tout est basé sur la déclaration de type standard de **Python 3.6** (grâce à Pydantic). Pas de nouvelles syntaxes à apprendre. Juste du Python standard et moderne.
Tout est basé sur la déclaration de type standard de **Python 3.8** (grâce à Pydantic). Pas de nouvelles syntaxes à apprendre. Juste du Python standard et moderne.
Si vous souhaitez un rappel de 2 minutes sur l'utilisation des types en Python (même si vous ne comptez pas utiliser FastAPI), jetez un oeil au tutoriel suivant: [Python Types](python-types.md){.internal-link target=_blank}.

6
docs/fr/docs/index.md

@ -27,7 +27,7 @@
---
FastAPI est un framework web moderne et rapide (haute performance) pour la création d'API avec Python 3.7+, basé sur les annotations de type standard de Python.
FastAPI est un framework web moderne et rapide (haute performance) pour la création d'API avec Python 3.8+, basé sur les annotations de type standard de Python.
Les principales fonctionnalités sont :
@ -115,7 +115,7 @@ Si vous souhaitez construire une application <abbr title="Command Line Interface
## Prérequis
Python 3.7+
Python 3.8+
FastAPI repose sur les épaules de géants :
@ -331,7 +331,7 @@ Vous faites cela avec les types Python standard modernes.
Vous n'avez pas à apprendre une nouvelle syntaxe, les méthodes ou les classes d'une bibliothèque spécifique, etc.
Juste du **Python 3.7+** standard.
Juste du **Python 3.8+** standard.
Par exemple, pour un `int`:

2
docs/ja/docs/features.md

@ -24,7 +24,7 @@
### 現代的なPython
FastAPIの機能はすべて、標準のPython 3.6型宣言に基づいています(Pydanticの功績)。新しい構文はありません。ただの現代的な標準のPythonです。
FastAPIの機能はすべて、標準のPython 3.8型宣言に基づいています(Pydanticの功績)。新しい構文はありません。ただの現代的な標準のPythonです。
(FastAPIを使用しない場合でも)Pythonの型の使用方法について簡単な復習が必要な場合は、短いチュートリアル([Python Types](python-types.md){.internal-link target=_blank})を参照してください。

2
docs/ja/docs/index.md

@ -107,7 +107,7 @@ FastAPI は、Pythonの標準である型ヒントに基づいてPython 3.6 以
## 必要条件
Python 3.7+
Python 3.8+
FastAPI は巨人の肩の上に立っています。

2
docs/ko/docs/index.md

@ -107,7 +107,7 @@ FastAPI는 현대적이고, 빠르며(고성능), 파이썬 표준 타입 힌트
## 요구사항
Python 3.7+
Python 3.8+
FastAPI는 거인들의 어깨 위에 서 있습니다:

2
docs/pl/docs/features.md

@ -25,7 +25,7 @@ Interaktywna dokumentacja i webowe interfejsy do eksploracji API. Z racji tego,
### Nowoczesny Python
Wszystko opiera się na standardowych deklaracjach typu **Python 3.6** (dzięki Pydantic). Brak nowej składni do uczenia. Po prostu standardowy, współczesny Python.
Wszystko opiera się na standardowych deklaracjach typu **Python 3.8** (dzięki Pydantic). Brak nowej składni do uczenia. Po prostu standardowy, współczesny Python.
Jeśli potrzebujesz szybkiego przypomnienia jak używać deklaracji typów w Pythonie (nawet jeśli nie używasz FastAPI), sprawdź krótki samouczek: [Python Types](python-types.md){.internal-link target=_blank}.

4
docs/pl/docs/index.md

@ -106,7 +106,7 @@ Jeżeli tworzysz aplikacje <abbr title="aplikacja z interfejsem konsolowym">CLI<
## Wymagania
Python 3.7+
Python 3.8+
FastAPI oparty jest na:
@ -321,7 +321,7 @@ Robisz to tak samo jak ze standardowymi typami w Pythonie.
Nie musisz sie uczyć żadnej nowej składni, metod lub klas ze specyficznych bibliotek itp.
Po prostu standardowy **Python 3.6+**.
Po prostu standardowy **Python 3.8+**.
Na przykład, dla danych typu `int`:

2
docs/pt/docs/features.md

@ -25,7 +25,7 @@ Documentação interativa da API e navegação _web_ da interface de usuário. C
### Apenas Python moderno
Tudo é baseado no padrão das declarações de **tipos do Python 3.6** (graças ao Pydantic). Nenhuma sintaxe nova para aprender. Apenas o padrão moderno do Python.
Tudo é baseado no padrão das declarações de **tipos do Python 3.8** (graças ao Pydantic). Nenhuma sintaxe nova para aprender. Apenas o padrão moderno do Python.
Se você precisa refrescar a memória rapidamente sobre como usar tipos do Python (mesmo que você não use o FastAPI), confira esse rápido tutorial: [Tipos do Python](python-types.md){.internal-link target=_blank}.

6
docs/pt/docs/index.md

@ -24,7 +24,7 @@
---
FastAPI é um moderno e rápido (alta performance) _framework web_ para construção de APIs com Python 3.6 ou superior, baseado nos _type hints_ padrões do Python.
FastAPI é um moderno e rápido (alta performance) _framework web_ para construção de APIs com Python 3.8 ou superior, baseado nos _type hints_ padrões do Python.
Os recursos chave são:
@ -100,7 +100,7 @@ Se você estiver construindo uma aplicação <abbr title="Command Line Interface
## Requisitos
Python 3.7+
Python 3.8+
FastAPI está nos ombros de gigantes:
@ -316,7 +316,7 @@ Você faz com tipos padrão do Python moderno.
Você não terá que aprender uma nova sintaxe, métodos ou classes de uma biblioteca específica etc.
Apenas **Python 3.6+** padrão.
Apenas **Python 3.8+** padrão.
Por exemplo, para um `int`:

10
docs/pt/docs/tutorial/body-multiple-params.md

@ -14,7 +14,7 @@ E você também pode declarar parâmetros de corpo como opcionais, definindo o v
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001.py!}
@ -44,7 +44,7 @@ Mas você pode também declarar múltiplos parâmetros de corpo, por exemplo, `i
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
@ -87,7 +87,7 @@ 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+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial003.py!}
@ -143,7 +143,7 @@ Por exemplo:
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004.py!}
@ -172,7 +172,7 @@ como em:
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005.py!}

2
docs/pt/docs/tutorial/encoder.md

@ -26,7 +26,7 @@ A função recebe um objeto, como um modelo Pydantic e retorna uma versão compa
{!> ../../../docs_src/encoder/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 22"
{!> ../../../docs_src/encoder/tutorial001.py!}

10
docs/pt/docs/tutorial/extra-models.md

@ -17,7 +17,7 @@ Isso é especialmente o caso para modelos de usuários, porque:
Aqui está uma ideia geral de como os modelos poderiam parecer com seus campos de senha e os lugares onde são usados:
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../../docs_src/extra_models/tutorial001.py!}
@ -158,7 +158,7 @@ Toda conversão de dados, validação, documentação, etc. ainda funcionará no
Dessa forma, podemos declarar apenas as diferenças entre os modelos (com `password` em texto claro, com `hashed_password` e sem senha):
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../../docs_src/extra_models/tutorial002.py!}
@ -181,7 +181,7 @@ Para fazer isso, use a dica de tipo padrão do Python <a href="https://docs.pyth
!!! note
Ao definir um <a href="https://pydantic-docs.helpmanual.io/usage/types/#unions" class="external-link" target="_blank">`Union`</a>, inclua o tipo mais específico primeiro, seguido pelo tipo menos específico. No exemplo abaixo, o tipo mais específico `PlaneItem` vem antes de `CarItem` em `Union[PlaneItem, CarItem]`.
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003.py!}
@ -213,7 +213,7 @@ Da mesma forma, você pode declarar respostas de listas de objetos.
Para isso, use o padrão Python `typing.List` (ou simplesmente `list` no Python 3.9 e superior):
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="1 20"
{!> ../../../docs_src/extra_models/tutorial004.py!}
@ -233,7 +233,7 @@ Isso é útil se você não souber os nomes de campo / atributo válidos (que se
Neste caso, você pode usar `typing.Dict` (ou simplesmente dict no Python 3.9 e superior):
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="1 8"
{!> ../../../docs_src/extra_models/tutorial005.py!}

8
docs/pt/docs/tutorial/header-params.md

@ -12,7 +12,7 @@ Primeiro importe `Header`:
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001.py!}
@ -30,7 +30,7 @@ O primeiro valor é o valor padrão, você pode passar todas as validações adi
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial001.py!}
@ -66,7 +66,7 @@ Se por algum motivo você precisar desabilitar a conversão automática de subli
{!> ../../../docs_src/header_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial002.py!}
@ -97,7 +97,7 @@ Por exemplo, para declarar um cabeçalho de `X-Token` que pode aparecer mais de
{!> ../../../docs_src/header_params/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial003.py!}

10
docs/pt/docs/tutorial/path-operation-configuration.md

@ -13,7 +13,7 @@ Você pode passar diretamente o código `int`, como `404`.
Mas se você não se lembrar o que cada código numérico significa, pode usar as constantes de atalho em `status`:
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
@ -42,7 +42,7 @@ Esse código de status será usado na resposta e será adicionado ao esquema Ope
Você pode adicionar tags para sua *operação de rota*, passe o parâmetro `tags` com uma `list` de `str` (comumente apenas um `str`):
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
@ -80,7 +80,7 @@ Nestes casos, pode fazer sentido armazenar as tags em um `Enum`.
Você pode adicionar um `summary` e uma `description`:
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
@ -104,7 +104,7 @@ Como as descrições tendem a ser longas e cobrir várias linhas, você pode dec
Você pode escrever <a href="https://en.wikipedia.org/wiki/Markdown" class="external-link" target="_blank">Markdown</a> na docstring, ele será interpretado e exibido corretamente (levando em conta a indentação da docstring).
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
@ -131,7 +131,7 @@ Ela será usada nas documentações interativas:
Você pode especificar a descrição da resposta com o parâmetro `response_description`:
=== "Python 3.6 and above"
=== "Python 3.8 and above"
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005.py!}

4
docs/pt/docs/tutorial/path-params-numeric-validations.md

@ -12,7 +12,7 @@ Primeiro, importe `Path` de `fastapi`:
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
@ -30,7 +30,7 @@ Por exemplo para declarar um valor de metadado `title` para o parâmetro de rota
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}

8
docs/pt/docs/tutorial/query-params.md

@ -69,7 +69,7 @@ Da mesma forma, você pode declarar parâmetros de consulta opcionais, definindo
{!> ../../../docs_src/query_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial002.py!}
@ -91,7 +91,7 @@ Você também pode declarar tipos `bool`, e eles serão convertidos:
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial003.py!}
@ -143,7 +143,7 @@ Eles serão detectados pelo nome:
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 10"
{!> ../../../docs_src/query_params/tutorial004.py!}
@ -209,7 +209,7 @@ E claro, você pode definir alguns parâmetros como obrigatórios, alguns possui
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params/tutorial006.py!}

2
docs/ru/docs/features.md

@ -27,7 +27,7 @@
### Только современный Python
Все эти возможности основаны на стандартных **аннотациях типов Python 3.6** (благодаря Pydantic). Не нужно изучать новый синтаксис. Только лишь стандартный современный Python.
Все эти возможности основаны на стандартных **аннотациях типов Python 3.8** (благодаря Pydantic). Не нужно изучать новый синтаксис. Только лишь стандартный современный Python.
Если вам нужно освежить знания, как использовать аннотации типов в Python (даже если вы не используете FastAPI), выделите 2 минуты и просмотрите краткое руководство: [Введение в аннотации типов Python¶
](python-types.md){.internal-link target=_blank}.

6
docs/ru/docs/index.md

@ -27,7 +27,7 @@
---
FastAPI — это современный, быстрый (высокопроизводительный) веб-фреймворк для создания API используя Python 3.6+, в основе которого лежит стандартная аннотация типов Python.
FastAPI — это современный, быстрый (высокопроизводительный) веб-фреймворк для создания API используя Python 3.8+, в основе которого лежит стандартная аннотация типов Python.
Ключевые особенности:
@ -109,7 +109,7 @@ FastAPI — это современный, быстрый (высокопрои
## Зависимости
Python 3.7+
Python 3.8+
FastAPI стоит на плечах гигантов:
@ -325,7 +325,7 @@ def update_item(item_id: int, item: Item):
Вам не нужно изучать новый синтаксис, методы или классы конкретной библиотеки и т. д.
Только стандартный **Python 3.6+**.
Только стандартный **Python 3.8+**.
Например, для `int`:

2
docs/ru/docs/tutorial/background-tasks.md

@ -63,7 +63,7 @@
{!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="13 15 22 25"
{!> ../../../docs_src/background_tasks/tutorial002.py!}

4
docs/ru/docs/tutorial/body-fields.md

@ -12,7 +12,7 @@
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001.py!}
@ -31,7 +31,7 @@
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11-14"
{!> ../../../docs_src/body_fields/tutorial001.py!}

18
docs/ru/docs/tutorial/body-multiple-params.md

@ -20,7 +20,7 @@
{!> ../../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
@ -35,7 +35,7 @@
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! Заметка
Рекомендуется использовать версию с `Annotated`, если это возможно.
@ -68,7 +68,7 @@
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
@ -123,7 +123,7 @@
{!> ../../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
@ -138,7 +138,7 @@
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! Заметка
Рекомендуется использовать `Annotated` версию, если это возможно.
@ -197,7 +197,7 @@ q: str | None = None
{!> ../../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="28"
{!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
@ -212,7 +212,7 @@ q: str | None = None
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! Заметка
Рекомендуется использовать `Annotated` версию, если это возможно.
@ -250,7 +250,7 @@ item: Item = Body(embed=True)
{!> ../../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
@ -265,7 +265,7 @@ item: Item = Body(embed=True)
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! Заметка
Рекомендуется использовать `Annotated` версию, если это возможно.

20
docs/ru/docs/tutorial/body-nested-models.md

@ -12,7 +12,7 @@
{!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial001.py!}
@ -73,7 +73,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
@ -99,7 +99,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14"
{!> ../../../docs_src/body_nested_models/tutorial003.py!}
@ -137,7 +137,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -159,7 +159,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -208,7 +208,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005.py!}
@ -232,7 +232,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006.py!}
@ -283,7 +283,7 @@ my_list: List[str]
{!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007.py!}
@ -314,7 +314,7 @@ images: list[Image]
{!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/body_nested_models/tutorial008.py!}
@ -354,7 +354,7 @@ images: list[Image]
{!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/body_nested_models/tutorial009.py!}

4
docs/ru/docs/tutorial/cookie-params.md

@ -12,7 +12,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001.py!}
@ -30,7 +30,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/cookie_params/tutorial001.py!}

4
docs/ru/docs/tutorial/dependencies/global-dependencies.md

@ -12,13 +12,13 @@
{!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial012_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip "Подсказка"
Рекомендуется использовать 'Annotated' версию, если это возможно.

4
docs/ru/docs/tutorial/extra-data-types.md

@ -55,7 +55,7 @@
Вот пример *операции пути* с параметрами, который демонстрирует некоторые из вышеперечисленных типов.
=== "Python 3.6 и выше"
=== "Python 3.8 и выше"
```Python hl_lines="1 3 12-16"
{!> ../../../docs_src/extra_data_types/tutorial001.py!}
@ -69,7 +69,7 @@
Обратите внимание, что параметры внутри функции имеют свой естественный тип данных, и вы, например, можете выполнять обычные манипуляции с датами, такие как:
=== "Python 3.6 и выше"
=== "Python 3.8 и выше"
```Python hl_lines="18-19"
{!> ../../../docs_src/extra_data_types/tutorial001.py!}

10
docs/ru/docs/tutorial/extra-models.md

@ -23,7 +23,7 @@
{!> ../../../docs_src/extra_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../../docs_src/extra_models/tutorial001.py!}
@ -164,7 +164,7 @@ UserInDB(
{!> ../../../docs_src/extra_models/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../../docs_src/extra_models/tutorial002.py!}
@ -187,7 +187,7 @@ UserInDB(
{!> ../../../docs_src/extra_models/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003.py!}
@ -219,7 +219,7 @@ some_variable: PlaneItem | CarItem
{!> ../../../docs_src/extra_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 20"
{!> ../../../docs_src/extra_models/tutorial004.py!}
@ -239,7 +239,7 @@ some_variable: PlaneItem | CarItem
{!> ../../../docs_src/extra_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 8"
{!> ../../../docs_src/extra_models/tutorial005.py!}

16
docs/ru/docs/tutorial/header-params.md

@ -18,7 +18,7 @@
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -33,7 +33,7 @@
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Предпочтительнее использовать версию с аннотацией, если это возможно.
@ -60,7 +60,7 @@
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -75,7 +75,7 @@
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Предпочтительнее использовать версию с аннотацией, если это возможно.
@ -120,7 +120,7 @@
{!> ../../../docs_src/header_params/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/header_params/tutorial002_an.py!}
@ -135,7 +135,7 @@
{!> ../../../docs_src/header_params/tutorial002_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Предпочтительнее использовать версию с аннотацией, если это возможно.
@ -169,7 +169,7 @@
{!> ../../../docs_src/header_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial003_an.py!}
@ -193,7 +193,7 @@
{!> ../../../docs_src/header_params/tutorial003_py39.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Предпочтительнее использовать версию с аннотацией, если это возможно.

10
docs/ru/docs/tutorial/path-operation-configuration.md

@ -25,7 +25,7 @@
{!> ../../../docs_src/path_operation_configuration/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
@ -54,7 +54,7 @@
{!> ../../../docs_src/path_operation_configuration/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
@ -92,7 +92,7 @@
{!> ../../../docs_src/path_operation_configuration/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
@ -116,7 +116,7 @@
{!> ../../../docs_src/path_operation_configuration/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
@ -142,7 +142,7 @@
{!> ../../../docs_src/path_operation_configuration/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005.py!}

26
docs/ru/docs/tutorial/path-params-numeric-validations.md

@ -18,7 +18,7 @@
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3-4"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -33,7 +33,7 @@
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -67,7 +67,7 @@
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -82,7 +82,7 @@
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -117,7 +117,7 @@
Поэтому вы можете определить функцию так:
=== "Python 3.6 без Annotated"
=== "Python 3.8 без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -134,7 +134,7 @@
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
@ -174,7 +174,7 @@ Python не будет ничего делать с `*`, но он будет з
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
@ -192,13 +192,13 @@ Python не будет ничего делать с `*`, но он будет з
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -220,13 +220,13 @@ Python не будет ничего делать с `*`, но он будет з
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -251,13 +251,13 @@ Python не будет ничего делать с `*`, но он будет з
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.

72
docs/ru/docs/tutorial/query-params-str-validations.md

@ -10,7 +10,7 @@
{!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
@ -42,7 +42,7 @@ Query-параметр `q` имеет тип `Union[str, None]` (или `str | N
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
В версиях Python ниже Python 3.9 `Annotation` импортируется из `typing_extensions`.
@ -66,7 +66,7 @@ Query-параметр `q` имеет тип `Union[str, None]` (или `str | N
q: str | None = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Union[str, None] = None
@ -80,7 +80,7 @@ Query-параметр `q` имеет тип `Union[str, None]` (или `str | N
q: Annotated[str | None] = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Annotated[Union[str, None]] = None
@ -100,7 +100,7 @@ Query-параметр `q` имеет тип `Union[str, None]` (или `str | N
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
@ -131,7 +131,7 @@ Query-параметр `q` имеет тип `Union[str, None]` (или `str | N
{!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
@ -244,7 +244,7 @@ q: str = Query(default="rick")
{!> ../../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
@ -259,7 +259,7 @@ q: str = Query(default="rick")
{!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -284,7 +284,7 @@ q: str = Query(default="rick")
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
@ -299,7 +299,7 @@ q: str = Query(default="rick")
{!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -330,13 +330,13 @@ q: str = Query(default="rick")
{!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -384,13 +384,13 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -414,13 +414,13 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -454,7 +454,7 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
@ -469,7 +469,7 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -491,13 +491,13 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 9"
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -527,7 +527,7 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
@ -551,7 +551,7 @@ q: Union[str, None] = None
{!> ../../../docs_src/query_params_str_validations/tutorial011_py39.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -596,7 +596,7 @@ http://localhost:8000/items/?q=foo&q=bar
{!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
@ -611,7 +611,7 @@ http://localhost:8000/items/?q=foo&q=bar
{!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -647,13 +647,13 @@ http://localhost:8000/items/
{!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -692,7 +692,7 @@ http://localhost:8000/items/
{!> ../../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
@ -707,7 +707,7 @@ http://localhost:8000/items/
{!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -730,7 +730,7 @@ http://localhost:8000/items/
{!> ../../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
@ -745,7 +745,7 @@ http://localhost:8000/items/
{!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -784,7 +784,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
@ -799,7 +799,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -828,7 +828,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
@ -843,7 +843,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.
@ -872,7 +872,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
@ -887,7 +887,7 @@ http://127.0.0.1:8000/items/?item-query=foobaritems
{!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать версию с `Annotated` если возможно.

8
docs/ru/docs/tutorial/query-params.md

@ -69,7 +69,7 @@ http://127.0.0.1:8000/items/?skip=20
{!> ../../../docs_src/query_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial002.py!}
@ -90,7 +90,7 @@ http://127.0.0.1:8000/items/?skip=20
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial003.py!}
@ -143,7 +143,7 @@ http://127.0.0.1:8000/items/foo?short=yes
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 10"
{!> ../../../docs_src/query_params/tutorial004.py!}
@ -209,7 +209,7 @@ http://127.0.0.1:8000/items/foo-item?needy=sooooneedy
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params/tutorial006.py!}

8
docs/ru/docs/tutorial/request-forms.md

@ -17,13 +17,13 @@
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать 'Annotated' версию, если это возможно.
@ -42,13 +42,13 @@
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
Рекомендуется использовать 'Annotated' версию, если это возможно.

28
docs/ru/docs/tutorial/response-model.md

@ -16,7 +16,7 @@ FastAPI позволяет использовать **аннотации тип
{!> ../../../docs_src/response_model/tutorial001_01_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18 23"
{!> ../../../docs_src/response_model/tutorial001_01.py!}
@ -65,7 +65,7 @@ FastAPI будет использовать этот возвращаемый т
{!> ../../../docs_src/response_model/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001.py!}
@ -101,7 +101,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -120,7 +120,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -145,7 +145,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -159,7 +159,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -173,7 +173,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -207,7 +207,7 @@ FastAPI будет использовать значение `response_model` д
{!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-13 15-16 20"
{!> ../../../docs_src/response_model/tutorial003_01.py!}
@ -283,7 +283,7 @@ FastAPI совместно с Pydantic выполнит некоторую ма
{!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/response_model/tutorial003_04.py!}
@ -305,7 +305,7 @@ FastAPI совместно с Pydantic выполнит некоторую ма
{!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/response_model/tutorial003_05.py!}
@ -329,7 +329,7 @@ FastAPI совместно с Pydantic выполнит некоторую ма
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11 13-14"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -359,7 +359,7 @@ FastAPI совместно с Pydantic выполнит некоторую ма
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -446,7 +446,7 @@ FastAPI достаточно умен (на самом деле, это засл
{!> ../../../docs_src/response_model/tutorial005_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial005.py!}
@ -467,7 +467,7 @@ FastAPI достаточно умен (на самом деле, это засл
{!> ../../../docs_src/response_model/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial006.py!}

12
docs/ru/docs/tutorial/schema-extra-example.md

@ -14,7 +14,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15-23"
{!> ../../../docs_src/schema_extra_example/tutorial001.py!}
@ -39,7 +39,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10-13"
{!> ../../../docs_src/schema_extra_example/tutorial002.py!}
@ -78,7 +78,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23-28"
{!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
@ -93,7 +93,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip Заметка
Рекомендуется использовать версию с `Annotated`, если это возможно.
@ -133,7 +133,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24-50"
{!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
@ -148,7 +148,7 @@
{!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip Заметка
Рекомендуется использовать версию с `Annotated`, если это возможно.

4
docs/ru/docs/tutorial/testing.md

@ -122,7 +122,7 @@
{!> ../../../docs_src/app_testing/app_b_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/app_testing/app_b_an/main.py!}
@ -137,7 +137,7 @@
{!> ../../../docs_src/app_testing/app_b_py310/main.py!}
```
=== "Python 3.6+ без Annotated"
=== "Python 3.8+ без Annotated"
!!! tip "Подсказка"
По возможности используйте версию с `Annotated`.

2
docs/tr/docs/features.md

@ -27,7 +27,7 @@ OpenAPI standartlarına dayalı olan bir framework olarak, geliştiricilerin bir
### Sadece modern Python
Tamamiyle standartlar **Python 3.6**'nın type hintlerine dayanıyor (Pydantic'in sayesinde). Yeni bir syntax öğrenmene gerek yok. Sadece modern Python.
Tamamiyle standartlar **Python 3.8**'nın type hintlerine dayanıyor (Pydantic'in sayesinde). Yeni bir syntax öğrenmene gerek yok. Sadece modern Python.
Eğer Python type hintlerini bilmiyorsan veya bir hatırlatmaya ihtiyacın var ise(FastAPI kullanmasan bile) şu iki dakikalık küçük bilgilendirici içeriğe bir göz at: [Python Types](python-types.md){.internal-link target=_blank}.

6
docs/tr/docs/index.md

@ -24,7 +24,7 @@
---
FastAPI, Python 3.6+'nın standart type hintlerine dayanan modern ve hızlı (yüksek performanslı) API'lar oluşturmak için kullanılabilecek web framework'ü.
FastAPI, Python 3.8+'nın standart type hintlerine dayanan modern ve hızlı (yüksek performanslı) API'lar oluşturmak için kullanılabilecek web framework'ü.
Ana özellikleri:
@ -115,7 +115,7 @@ Eğer API yerine <abbr title="Command Line Interface">komut satırı uygulaması
## Gereksinimler
Python 3.7+
Python 3.8+
FastAPI iki devin omuzları üstünde duruyor:
@ -331,7 +331,7 @@ Type-hinting işlemini Python dilindeki standart veri tipleri ile yapabilirsin
Yeni bir syntax'e alışmana gerek yok, metodlar ve classlar zaten spesifik kütüphanelere ait.
Sadece standart **Python 3.6+**.
Sadece standart **Python 3.8+**.
Örnek olarak, `int` tanımlamak için:

22
docs/uk/docs/python-types.md

@ -164,7 +164,7 @@ John Doe
Наприклад, давайте визначимо змінну, яка буде `list` із `str`.
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
З модуля `typing`, імпортуємо `List` (з великої літери `L`):
@ -218,7 +218,7 @@ John Doe
Ви повинні зробити те ж саме, щоб оголосити `tuple` і `set`:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
@ -243,7 +243,7 @@ John Doe
Другий параметр типу для значення у `dict`:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
@ -269,7 +269,7 @@ John Doe
У Python 3.10 також є **альтернативний синтаксис**, у якому ви можете розділити можливі типи за допомогою <abbr title='також називають «побітовим "або" оператором», але це значення тут не актуальне'>вертикальної смуги (`|`)</abbr>.
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
@ -299,13 +299,13 @@ John Doe
Це також означає, що в Python 3.10 ви можете використовувати `Something | None`:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
```
=== "Python 3.6 і вище - альтернатива"
=== "Python 3.8 і вище - альтернатива"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
@ -321,7 +321,7 @@ John Doe
Ці типи, які приймають параметри типу у квадратних дужках, називаються **Generic types** or **Generics**, наприклад:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
* `List`
* `Tuple`
@ -340,7 +340,7 @@ John Doe
* `set`
* `dict`
І те саме, що й у Python 3.6, із модуля `typing`:
І те саме, що й у Python 3.8, із модуля `typing`:
* `Union`
* `Optional`
@ -355,10 +355,10 @@ John Doe
* `set`
* `dict`
І те саме, що й у Python 3.6, із модуля `typing`:
І те саме, що й у Python 3.8, із модуля `typing`:
* `Union`
* `Optional` (так само як у Python 3.6)
* `Optional` (так само як у Python 3.8)
* ...та інші.
У Python 3.10, як альтернатива використанню `Union` та `Optional`, ви можете використовувати <abbr title='також називають «побітовим "або" оператором», але це значення тут не актуальне'>вертикальну смугу (`|`)</abbr> щоб оголосити об'єднання типів.
@ -397,7 +397,7 @@ John Doe
Приклад з документації Pydantic:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}

12
docs/uk/docs/tutorial/body.md

@ -19,7 +19,7 @@
Спочатку вам потрібно імпортувати `BaseModel` з `pydantic`:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
@ -37,7 +37,7 @@
Використовуйте стандартні типи Python для всіх атрибутів:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
@ -75,7 +75,7 @@
Щоб додати модель даних до вашої *операції шляху*, оголосіть її так само, як ви оголосили параметри шляху та запиту:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
@ -149,7 +149,7 @@
Усередині функції ви можете отримати прямий доступ до всіх атрибутів об’єкта моделі:
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
@ -167,7 +167,7 @@
**FastAPI** розпізнає, що параметри функції, які відповідають параметрам шляху, мають бути **взяті з шляху**, а параметри функції, які оголошуються як моделі Pydantic, **взяті з тіла запиту**.
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
@ -185,7 +185,7 @@
**FastAPI** розпізнає кожен з них і візьме дані з потрібного місця.
=== "Python 3.6 і вище"
=== "Python 3.8 і вище"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}

8
docs/uk/docs/tutorial/cookie-params.md

@ -18,7 +18,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -33,7 +33,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Бажано використовувати `Annotated` версію, якщо це можливо.
@ -60,7 +60,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -75,7 +75,7 @@
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Бажано використовувати `Annotated` версію, якщо це можливо.

2
docs/uk/docs/tutorial/encoder.md

@ -26,7 +26,7 @@
{!> ../../../docs_src/encoder/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 22"
{!> ../../../docs_src/encoder/tutorial001.py!}

8
docs/uk/docs/tutorial/extra-data-types.md

@ -67,7 +67,7 @@
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 3 13-17"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -82,7 +82,7 @@
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Бажано використовувати `Annotated` версію, якщо це можливо.
@ -105,7 +105,7 @@
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-20"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -120,7 +120,7 @@
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Бажано використовувати `Annotated` версію, якщо це можливо.

2
docs/vi/docs/features.md

@ -26,7 +26,7 @@ Tài liệu tương tác API và web giao diện người dùng. Là một frame
### Chỉ cần phiên bản Python hiện đại
Tất cả được dựa trên khai báo kiểu dữ liệu chuẩn của **Python 3.6** (cảm ơn Pydantic). Bạn không cần học cú pháp mới, chỉ cần biết chuẩn Python hiện đại.
Tất cả được dựa trên khai báo kiểu dữ liệu chuẩn của **Python 3.8** (cảm ơn Pydantic). Bạn không cần học cú pháp mới, chỉ cần biết chuẩn Python hiện đại.
Nếu bạn cần 2 phút để làm mới lại cách sử dụng các kiểu dữ liệu mới của Python (thậm chí nếu bạn không sử dụng FastAPI), xem hướng dẫn ngắn: [Kiểu dữ liệu Python](python-types.md){.internal-link target=_blank}.

6
docs/vi/docs/index.md

@ -27,7 +27,7 @@
---
FastAPI là một web framework hiện đại, hiệu năng cao để xây dựng web APIs với Python 3.7+ dựa trên tiêu chuẩn Python type hints.
FastAPI là một web framework hiện đại, hiệu năng cao để xây dựng web APIs với Python 3.8+ dựa trên tiêu chuẩn Python type hints.
Những tính năng như:
@ -116,7 +116,7 @@ Nếu bạn đang xây dựng một <abbr title="Giao diện dòng lệnh">CLI</
## Yêu cầu
Python 3.7+
Python 3.8+
FastAPI đứng trên vai những người khổng lồ:
@ -332,7 +332,7 @@ Bạn định nghĩa bằng cách sử dụng các kiểu dữ liệu chuẩn c
Bạn không phải học một cú pháp mới, các phương thức và class của một thư viện cụ thể nào.
Chỉ cần sử dụng các chuẩn của **Python 3.7+**.
Chỉ cần sử dụng các chuẩn của **Python 3.8+**.
Ví dụ, với một tham số kiểu `int`:

18
docs/vi/docs/python-types.md

@ -182,7 +182,7 @@ Ví dụ, hãy định nghĩa một biến là `list` các `str`.
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
Từ `typing`, import `List` (với chữ cái `L` viết hoa):
@ -230,7 +230,7 @@ Bạn sẽ làm điều tương tự để khai báo các `tuple` và các `set
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
@ -255,7 +255,7 @@ Tham số kiểu dữ liệu thứ hai dành cho giá trị của `dict`.
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
@ -284,7 +284,7 @@ Trong Python 3.10 cũng có một **cú pháp mới** mà bạn có thể đặt
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
@ -314,13 +314,13 @@ Sử dụng `Optional[str]` thay cho `str` sẽ cho phép trình soạn thảo g
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
```
=== "Python 3.6+ alternative"
=== "Python 3.8+ alternative"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
@ -404,7 +404,7 @@ Những kiểu dữ liệu này lấy tham số kiểu dữ liệu trong dấu n
* `Optional`
* ...and others.
=== "Python 3.6+"
=== "Python 3.8+"
* `List`
* `Tuple`
@ -464,7 +464,7 @@ Một ví dụ từ tài liệu chính thức của Pydantic:
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
@ -493,7 +493,7 @@ Python cũng có một tính năng cho phép đặt **metadata bổ sung** trong
{!> ../../../docs_src/python_types/tutorial013_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
Ở phiên bản dưới Python 3.9, bạn import `Annotated` từ `typing_extensions`.

6
docs/yo/docs/index.md

@ -27,7 +27,7 @@
---
FastAPI jẹ́ ìgbàlódé, tí ó yára (iṣẹ-giga), ìlànà wẹ́ẹ́bù fún kikọ àwọn API pẹ̀lú Python 3.7+ èyí tí ó da lori àwọn ìtọ́kasí àmì irúfẹ́ Python.
FastAPI jẹ́ ìgbàlódé, tí ó yára (iṣẹ-giga), ìlànà wẹ́ẹ́bù fún kikọ àwọn API pẹ̀lú Python 3.8+ èyí tí ó da lori àwọn ìtọ́kasí àmì irúfẹ́ Python.
Àwọn ẹya pàtàkì ni:
@ -115,7 +115,7 @@ Ti o ba n kọ ohun èlò <abbr title="Command Line Interface">CLI</abbr> láti
## Èròjà
Python 3.7+
Python 3.8+
FastAPI dúró lórí àwọn èjìká tí àwọn òmíràn:
@ -331,7 +331,7 @@ O ṣe ìyẹn pẹ̀lú irúfẹ́ àmì ìtọ́kasí ìgbàlódé Python.
O ò nílò láti kọ́ síńtáàsì tuntun, ìlànà tàbí ọ̀wọ́ kíláàsì kan pàtó, abbl (i.e. àti bẹbẹ lọ).
Ìtọ́kasí **Python 3.7+**
Ìtọ́kasí **Python 3.8+**
Fún àpẹẹrẹ, fún `int`:

6
docs/zh/docs/advanced/generate-clients.md

@ -22,7 +22,7 @@
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
@ -134,7 +134,7 @@ [email protected] generate-client /home/user/code/frontend-app
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
@ -191,7 +191,7 @@ FastAPI为每个*路径操作*使用一个**唯一ID**,它用于**操作ID**
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}

12
docs/zh/docs/advanced/settings.md

@ -223,13 +223,13 @@ $ ADMIN_EMAIL="[email protected]" APP_NAME="ChimichangApp"uvicorn main:app
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="6 12-13"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ 非注解版本"
=== "Python 3.8+ 非注解版本"
!!! tip
如果可能,请尽量使用 `Annotated` 版本。
@ -251,13 +251,13 @@ $ ADMIN_EMAIL="[email protected]" APP_NAME="ChimichangApp"uvicorn main:app
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 19-21"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ 非注解版本"
=== "Python 3.8+ 非注解版本"
!!! tip
如果可能,请尽量使用 `Annotated` 版本。
@ -345,13 +345,13 @@ def get_settings():
{!> ../../../docs_src/settings/app03_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 11"
{!> ../../../docs_src/settings/app03_an/main.py!}
```
=== "Python 3.6+ 非注解版本"
=== "Python 3.8+ 非注解版本"
!!! tip
如果可能,请尽量使用 `Annotated` 版本。

6
docs/zh/docs/advanced/websockets.md

@ -118,7 +118,7 @@ $ uvicorn main:app --reload
{!> ../../../docs_src/websockets/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="69-70 83"
{!> ../../../docs_src/websockets/tutorial002_an.py!}
@ -133,7 +133,7 @@ $ uvicorn main:app --reload
{!> ../../../docs_src/websockets/tutorial002_py310.py!}
```
=== "Python 3.6+ 非带注解版本"
=== "Python 3.8+ 非带注解版本"
!!! tip
如果可能,请尽量使用 `Annotated` 版本。
@ -181,7 +181,7 @@ $ uvicorn main:app --reload
{!> ../../../docs_src/websockets/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="81-83"
{!> ../../../docs_src/websockets/tutorial003.py!}

6
docs/zh/docs/index.md

@ -24,7 +24,7 @@
---
FastAPI 是一个用于构建 API 的现代、快速(高性能)的 web 框架,使用 Python 3.6+ 并基于标准的 Python 类型提示。
FastAPI 是一个用于构建 API 的现代、快速(高性能)的 web 框架,使用 Python 3.8+ 并基于标准的 Python 类型提示。
关键特性:
@ -107,7 +107,7 @@ FastAPI 是一个用于构建 API 的现代、快速(高性能)的 web 框
## 依赖
Python 3.6 及更高版本
Python 3.8 及更高版本
FastAPI 站在以下巨人的肩膀之上:
@ -323,7 +323,7 @@ def update_item(item_id: int, item: Item):
你不需要去学习新的语法、了解特定库的方法或类,等等。
只需要使用标准的 **Python 3.6 及更高版本**
只需要使用标准的 **Python 3.8 及更高版本**
举个例子,比如声明 `int` 类型:

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save