mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-03 19:50:52 -05:00
Compare commits
7 Commits
translate-
...
0.127.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd90c78391 | ||
|
|
93f4dfd88b | ||
|
|
535b5daa31 | ||
|
|
6b53786f62 | ||
|
|
d98f4eb56e | ||
|
|
8cefc4b7cc | ||
|
|
3063ada72f |
@@ -12,15 +12,23 @@ repos:
|
||||
- --unsafe
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.14.3
|
||||
hooks:
|
||||
- id: ruff
|
||||
args:
|
||||
- --fix
|
||||
- id: ruff-format
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: local-ruff-check
|
||||
name: ruff check
|
||||
entry: uv run ruff check --force-exclude --fix --exit-non-zero-on-fix
|
||||
require_serial: true
|
||||
language: unsupported
|
||||
types: [python]
|
||||
|
||||
- id: local-ruff-format
|
||||
name: ruff format
|
||||
entry: uv run ruff format --force-exclude --exit-non-zero-on-format
|
||||
require_serial: true
|
||||
language: unsupported
|
||||
types: [python]
|
||||
|
||||
- id: add-permalinks-pages
|
||||
language: unsupported
|
||||
name: add-permalinks-pages
|
||||
@@ -28,18 +36,21 @@ repos:
|
||||
args:
|
||||
- --update-existing
|
||||
files: ^docs/en/docs/.*\.md$
|
||||
|
||||
- id: generate-readme
|
||||
language: unsupported
|
||||
name: generate README.md from index.md
|
||||
entry: uv run ./scripts/docs.py generate-readme
|
||||
files: ^docs/en/docs/index\.md|docs/en/data/sponsors\.yml|scripts/docs\.py$
|
||||
pass_filenames: false
|
||||
|
||||
- id: update-languages
|
||||
language: unsupported
|
||||
name: update languages
|
||||
entry: uv run ./scripts/docs.py update-languages
|
||||
files: ^docs/.*|scripts/docs\.py$
|
||||
pass_filenames: false
|
||||
|
||||
- id: ensure-non-translated
|
||||
language: unsupported
|
||||
name: ensure non-translated files are not modified
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI basiert auf **Pydantic**, und ich habe Ihnen gezeigt, wie Sie Pydantic-M
|
||||
|
||||
Aber FastAPI unterstützt auf die gleiche Weise auch die Verwendung von <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a>:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
|
||||
Das ist dank **Pydantic** ebenfalls möglich, da es <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">`dataclasses` intern unterstützt</a>.
|
||||
|
||||
@@ -32,7 +32,7 @@ Wenn Sie jedoch eine Menge Datenklassen herumliegen haben, ist dies ein guter Tr
|
||||
|
||||
Sie können `dataclasses` auch im Parameter `response_model` verwenden:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
|
||||
Die Datenklasse wird automatisch in eine Pydantic-Datenklasse konvertiert.
|
||||
|
||||
@@ -48,7 +48,7 @@ In einigen Fällen müssen Sie möglicherweise immer noch Pydantics Version von
|
||||
|
||||
In diesem Fall können Sie einfach die Standard-`dataclasses` durch `pydantic.dataclasses` ersetzen, was einen direkten Ersatz darstellt:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
|
||||
1. Wir importieren `field` weiterhin von Standard-`dataclasses`.
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Abhängig von Ihrem Anwendungsfall könnten Sie eine andere Bibliothek vorziehen
|
||||
|
||||
Hier ist eine kleine Vorschau, wie Sie Strawberry mit FastAPI integrieren können:
|
||||
|
||||
{* ../../docs_src/graphql/tutorial001_py39.py hl[3,22,25] *}
|
||||
{* ../../docs_src/graphql_/tutorial001_py39.py hl[3,22,25] *}
|
||||
|
||||
Weitere Informationen zu Strawberry finden Sie in der <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry-Dokumentation</a>.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI is built on top of **Pydantic**, and I have been showing you how to use
|
||||
|
||||
But FastAPI also supports using <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a> the same way:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
|
||||
This is still supported thanks to **Pydantic**, as it has <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">internal support for `dataclasses`</a>.
|
||||
|
||||
@@ -32,7 +32,7 @@ But if you have a bunch of dataclasses laying around, this is a nice trick to us
|
||||
|
||||
You can also use `dataclasses` in the `response_model` parameter:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
|
||||
The dataclass will be automatically converted to a Pydantic dataclass.
|
||||
|
||||
@@ -48,7 +48,7 @@ In some cases, you might still have to use Pydantic's version of `dataclasses`.
|
||||
|
||||
In that case, you can simply swap the standard `dataclasses` with `pydantic.dataclasses`, which is a drop-in replacement:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
|
||||
1. We still import `field` from standard `dataclasses`.
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Depending on your use case, you might prefer to use a different library, but if
|
||||
|
||||
Here's a small preview of how you could integrate Strawberry with FastAPI:
|
||||
|
||||
{* ../../docs_src/graphql/tutorial001_py39.py hl[3,22,25] *}
|
||||
{* ../../docs_src/graphql_/tutorial001_py39.py hl[3,22,25] *}
|
||||
|
||||
You can learn more about Strawberry in the <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry documentation</a>.
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@ hide:
|
||||
|
||||
## Latest Changes
|
||||
|
||||
## 0.127.1
|
||||
|
||||
### Refactors
|
||||
|
||||
* 🔊 Add a custom `FastAPIDeprecationWarning`. PR [#14605](https://github.com/fastapi/fastapi/pull/14605) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Docs
|
||||
|
||||
* 📝 Add documentary to website. PR [#14600](https://github.com/fastapi/fastapi/pull/14600) by [@tiangolo](https://github.com/tiangolo).
|
||||
@@ -18,6 +24,8 @@ hide:
|
||||
|
||||
### Internal
|
||||
|
||||
* 🔧 Update pre-commit to use local Ruff instead of hook. PR [#14604](https://github.com/fastapi/fastapi/pull/14604) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ✅ Add missing tests for code examples. PR [#14569](https://github.com/fastapi/fastapi/pull/14569) by [@YuriiMotov](https://github.com/YuriiMotov).
|
||||
* 👷 Remove `lint` job from `test` CI workflow. PR [#14593](https://github.com/fastapi/fastapi/pull/14593) by [@YuriiMotov](https://github.com/YuriiMotov).
|
||||
* 👷 Update secrets check. PR [#14592](https://github.com/fastapi/fastapi/pull/14592) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Run CodSpeed tests in parallel to other tests to speed up CI. PR [#14586](https://github.com/fastapi/fastapi/pull/14586) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI está construido sobre **Pydantic**, y te he estado mostrando cómo usar
|
||||
|
||||
Pero FastAPI también soporta el uso de <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a> de la misma manera:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
|
||||
Esto sigue siendo soportado gracias a **Pydantic**, ya que tiene <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">soporte interno para `dataclasses`</a>.
|
||||
|
||||
@@ -32,7 +32,7 @@ Pero si tienes un montón de dataclasses por ahí, este es un buen truco para us
|
||||
|
||||
También puedes usar `dataclasses` en el parámetro `response_model`:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
|
||||
El dataclass será automáticamente convertido a un dataclass de Pydantic.
|
||||
|
||||
@@ -48,7 +48,7 @@ En algunos casos, todavía podrías tener que usar la versión de `dataclasses`
|
||||
|
||||
En ese caso, simplemente puedes intercambiar los `dataclasses` estándar con `pydantic.dataclasses`, que es un reemplazo directo:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
|
||||
1. Todavía importamos `field` de los `dataclasses` estándar.
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Dependiendo de tu caso de uso, podrías preferir usar un paquete diferente, pero
|
||||
|
||||
Aquí tienes una pequeña vista previa de cómo podrías integrar Strawberry con FastAPI:
|
||||
|
||||
{* ../../docs_src/graphql/tutorial001_py39.py hl[3,22,25] *}
|
||||
{* ../../docs_src/graphql_/tutorial001_py39.py hl[3,22,25] *}
|
||||
|
||||
Puedes aprender más sobre Strawberry en la <a href="https://strawberry.rocks/" class="external-link" target="_blank">documentación de Strawberry</a>.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI é construído em cima do **Pydantic**, e eu tenho mostrado como usar mo
|
||||
|
||||
Mas o FastAPI também suporta o uso de <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a> da mesma forma:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
|
||||
Isso ainda é suportado graças ao **Pydantic**, pois ele tem <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">suporte interno para `dataclasses`</a>.
|
||||
|
||||
@@ -32,7 +32,7 @@ Mas se você tem um monte de dataclasses por aí, este é um truque legal para u
|
||||
|
||||
Você também pode usar `dataclasses` no parâmetro `response_model`:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
|
||||
A dataclass será automaticamente convertida para uma dataclass Pydantic.
|
||||
|
||||
@@ -48,7 +48,7 @@ Em alguns casos, você ainda pode ter que usar a versão do Pydantic das `datacl
|
||||
|
||||
Nesse caso, você pode simplesmente trocar as `dataclasses` padrão por `pydantic.dataclasses`, que é um substituto direto:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
|
||||
1. Ainda importamos `field` das `dataclasses` padrão.
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Dependendo do seu caso de uso, você pode preferir usar uma biblioteca diferente
|
||||
|
||||
Aqui está uma pequena prévia de como você poderia integrar Strawberry com FastAPI:
|
||||
|
||||
{* ../../docs_src/graphql/tutorial001_py39.py hl[3,22,25] *}
|
||||
{* ../../docs_src/graphql_/tutorial001_py39.py hl[3,22,25] *}
|
||||
|
||||
Você pode aprender mais sobre Strawberry na <a href="https://strawberry.rocks/" class="external-link" target="_blank">documentação do Strawberry</a>.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI построен поверх **Pydantic**, и я показывал в
|
||||
|
||||
Но FastAPI также поддерживает использование <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a> тем же способом:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
|
||||
|
||||
Это по-прежнему поддерживается благодаря **Pydantic**, так как в нём есть <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">встроенная поддержка `dataclasses`</a>.
|
||||
|
||||
@@ -32,7 +32,7 @@ FastAPI построен поверх **Pydantic**, и я показывал в
|
||||
|
||||
Вы также можете использовать `dataclasses` в параметре `response_model`:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002_py310.py hl[1,6:12,18] *}
|
||||
|
||||
Этот dataclass будет автоматически преобразован в Pydantic dataclass.
|
||||
|
||||
@@ -48,7 +48,7 @@ FastAPI построен поверх **Pydantic**, и я показывал в
|
||||
|
||||
В таком случае вы можете просто заменить стандартные `dataclasses` на `pydantic.dataclasses`, которая является полностью совместимой заменой (drop-in replacement):
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
|
||||
|
||||
1. Мы по-прежнему импортируем `field` из стандартных `dataclasses`.
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
Вот небольшой пример того, как можно интегрировать Strawberry с FastAPI:
|
||||
|
||||
{* ../../docs_src/graphql/tutorial001_py39.py hl[3,22,25] *}
|
||||
{* ../../docs_src/graphql_/tutorial001_py39.py hl[3,22,25] *}
|
||||
|
||||
Подробнее о Strawberry можно узнать в <a href="https://strawberry.rocks/" class="external-link" target="_blank">документации Strawberry</a>.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ FastAPI 基于 **Pydantic** 构建,前文已经介绍过如何使用 Pydantic
|
||||
|
||||
但 FastAPI 还可以使用数据类(<a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a>):
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial001.py hl[1,7:12,19:20] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial001.py hl[1,7:12,19:20] *}
|
||||
|
||||
这还是借助于 **Pydantic** 及其<a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">内置的 `dataclasses`</a>。
|
||||
|
||||
@@ -32,7 +32,7 @@ FastAPI 基于 **Pydantic** 构建,前文已经介绍过如何使用 Pydantic
|
||||
|
||||
在 `response_model` 参数中使用 `dataclasses`:
|
||||
|
||||
{* ../../docs_src/dataclasses/tutorial002.py hl[1,7:13,19] *}
|
||||
{* ../../docs_src/dataclasses_/tutorial002.py hl[1,7:13,19] *}
|
||||
|
||||
本例把数据类自动转换为 Pydantic 数据类。
|
||||
|
||||
@@ -49,7 +49,7 @@ API 文档中也会显示相关概图:
|
||||
本例把标准的 `dataclasses` 直接替换为 `pydantic.dataclasses`:
|
||||
|
||||
```{ .python .annotate hl_lines="1 5 8-11 14-17 23-25 28" }
|
||||
{!../../docs_src/dataclasses/tutorial003.py!}
|
||||
{!../../docs_src/dataclasses_/tutorial003.py!}
|
||||
```
|
||||
|
||||
1. 本例依然要从标准的 `dataclasses` 中导入 `field`;
|
||||
|
||||
0
docs_src/additional_responses/__init__.py
Normal file
0
docs_src/additional_responses/__init__.py
Normal file
0
docs_src/additional_status_codes/__init__.py
Normal file
0
docs_src/additional_status_codes/__init__.py
Normal file
0
docs_src/advanced_middleware/__init__.py
Normal file
0
docs_src/advanced_middleware/__init__.py
Normal file
0
docs_src/background_tasks/__init__.py
Normal file
0
docs_src/background_tasks/__init__.py
Normal file
0
docs_src/behind_a_proxy/__init__.py
Normal file
0
docs_src/behind_a_proxy/__init__.py
Normal file
0
docs_src/body/__init__.py
Normal file
0
docs_src/body/__init__.py
Normal file
0
docs_src/body_fields/__init__.py
Normal file
0
docs_src/body_fields/__init__.py
Normal file
0
docs_src/body_multiple_params/__init__.py
Normal file
0
docs_src/body_multiple_params/__init__.py
Normal file
0
docs_src/body_nested_models/__init__.py
Normal file
0
docs_src/body_nested_models/__init__.py
Normal file
0
docs_src/body_updates/__init__.py
Normal file
0
docs_src/body_updates/__init__.py
Normal file
0
docs_src/conditional_openapi/__init__.py
Normal file
0
docs_src/conditional_openapi/__init__.py
Normal file
0
docs_src/configure_swagger_ui/__init__.py
Normal file
0
docs_src/configure_swagger_ui/__init__.py
Normal file
0
docs_src/cookie_param_models/__init__.py
Normal file
0
docs_src/cookie_param_models/__init__.py
Normal file
0
docs_src/cookie_params/__init__.py
Normal file
0
docs_src/cookie_params/__init__.py
Normal file
0
docs_src/cors/__init__.py
Normal file
0
docs_src/cors/__init__.py
Normal file
0
docs_src/custom_docs_ui/__init__.py
Normal file
0
docs_src/custom_docs_ui/__init__.py
Normal file
0
docs_src/custom_request_and_route/__init__.py
Normal file
0
docs_src/custom_request_and_route/__init__.py
Normal file
0
docs_src/custom_response/__init__.py
Normal file
0
docs_src/custom_response/__init__.py
Normal file
0
docs_src/dataclasses_/__init__.py
Normal file
0
docs_src/dataclasses_/__init__.py
Normal file
0
docs_src/debugging/__init__.py
Normal file
0
docs_src/debugging/__init__.py
Normal file
0
docs_src/dependencies/__init__.py
Normal file
0
docs_src/dependencies/__init__.py
Normal file
0
docs_src/dependency_testing/__init__.py
Normal file
0
docs_src/dependency_testing/__init__.py
Normal file
0
docs_src/encoder/__init__.py
Normal file
0
docs_src/encoder/__init__.py
Normal file
0
docs_src/events/__init__.py
Normal file
0
docs_src/events/__init__.py
Normal file
0
docs_src/extending_openapi/__init__.py
Normal file
0
docs_src/extending_openapi/__init__.py
Normal file
0
docs_src/extra_data_types/__init__.py
Normal file
0
docs_src/extra_data_types/__init__.py
Normal file
0
docs_src/extra_models/__init__.py
Normal file
0
docs_src/extra_models/__init__.py
Normal file
0
docs_src/first_steps/__init__.py
Normal file
0
docs_src/first_steps/__init__.py
Normal file
0
docs_src/generate_clients/__init__.py
Normal file
0
docs_src/generate_clients/__init__.py
Normal file
0
docs_src/graphql_/__init__.py
Normal file
0
docs_src/graphql_/__init__.py
Normal file
0
docs_src/handling_errors/__init__.py
Normal file
0
docs_src/handling_errors/__init__.py
Normal file
0
docs_src/header_param_models/__init__.py
Normal file
0
docs_src/header_param_models/__init__.py
Normal file
0
docs_src/header_params/__init__.py
Normal file
0
docs_src/header_params/__init__.py
Normal file
0
docs_src/metadata/__init__.py
Normal file
0
docs_src/metadata/__init__.py
Normal file
0
docs_src/middleware/__init__.py
Normal file
0
docs_src/middleware/__init__.py
Normal file
0
docs_src/openapi_callbacks/__init__.py
Normal file
0
docs_src/openapi_callbacks/__init__.py
Normal file
0
docs_src/openapi_webhooks/__init__.py
Normal file
0
docs_src/openapi_webhooks/__init__.py
Normal file
0
docs_src/path_operation_configuration/__init__.py
Normal file
0
docs_src/path_operation_configuration/__init__.py
Normal file
0
docs_src/path_params/__init__.py
Normal file
0
docs_src/path_params/__init__.py
Normal file
0
docs_src/pydantic_v1_in_v2/__init__.py
Normal file
0
docs_src/pydantic_v1_in_v2/__init__.py
Normal file
0
docs_src/python_types/__init__.py
Normal file
0
docs_src/python_types/__init__.py
Normal file
0
docs_src/query_param_models/__init__.py
Normal file
0
docs_src/query_param_models/__init__.py
Normal file
0
docs_src/query_params/__init__.py
Normal file
0
docs_src/query_params/__init__.py
Normal file
0
docs_src/query_params_str_validations/__init__.py
Normal file
0
docs_src/query_params_str_validations/__init__.py
Normal file
0
docs_src/request_files/__init__.py
Normal file
0
docs_src/request_files/__init__.py
Normal file
0
docs_src/request_form_models/__init__.py
Normal file
0
docs_src/request_form_models/__init__.py
Normal file
0
docs_src/request_forms/__init__.py
Normal file
0
docs_src/request_forms/__init__.py
Normal file
0
docs_src/request_forms_and_files/__init__.py
Normal file
0
docs_src/request_forms_and_files/__init__.py
Normal file
0
docs_src/response_change_status_code/__init__.py
Normal file
0
docs_src/response_change_status_code/__init__.py
Normal file
0
docs_src/response_cookies/__init__.py
Normal file
0
docs_src/response_cookies/__init__.py
Normal file
0
docs_src/response_directly/__init__.py
Normal file
0
docs_src/response_directly/__init__.py
Normal file
0
docs_src/response_headers/__init__.py
Normal file
0
docs_src/response_headers/__init__.py
Normal file
0
docs_src/response_model/__init__.py
Normal file
0
docs_src/response_model/__init__.py
Normal file
0
docs_src/response_status_code/__init__.py
Normal file
0
docs_src/response_status_code/__init__.py
Normal file
0
docs_src/schema_extra_example/__init__.py
Normal file
0
docs_src/schema_extra_example/__init__.py
Normal file
0
docs_src/security/__init__.py
Normal file
0
docs_src/security/__init__.py
Normal file
0
docs_src/separate_openapi_schemas/__init__.py
Normal file
0
docs_src/separate_openapi_schemas/__init__.py
Normal file
0
docs_src/settings/__init__.py
Normal file
0
docs_src/settings/__init__.py
Normal file
0
docs_src/static_files/__init__.py
Normal file
0
docs_src/static_files/__init__.py
Normal file
0
docs_src/sub_applications/__init__.py
Normal file
0
docs_src/sub_applications/__init__.py
Normal file
0
docs_src/templates/__init__.py
Normal file
0
docs_src/templates/__init__.py
Normal file
0
docs_src/templates/static/__init__.py
Normal file
0
docs_src/templates/static/__init__.py
Normal file
0
docs_src/templates/templates/__init__.py
Normal file
0
docs_src/templates/templates/__init__.py
Normal file
0
docs_src/using_request_directly/__init__.py
Normal file
0
docs_src/using_request_directly/__init__.py
Normal file
0
docs_src/wsgi/__init__.py
Normal file
0
docs_src/wsgi/__init__.py
Normal file
@@ -1,6 +1,6 @@
|
||||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||
|
||||
__version__ = "0.127.0"
|
||||
__version__ = "0.127.1"
|
||||
|
||||
from starlette import status as status
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ from fastapi.concurrency import (
|
||||
contextmanager_in_threadpool,
|
||||
)
|
||||
from fastapi.dependencies.models import Dependant
|
||||
from fastapi.exceptions import DependencyScopeError
|
||||
from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning
|
||||
from fastapi.logger import logger
|
||||
from fastapi.security.oauth2 import SecurityScopes
|
||||
from fastapi.types import DependencyCacheKey
|
||||
@@ -327,7 +327,7 @@ def get_dependant(
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" Please update the param {param_name}: {param_details.type_annotation!r}.",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=5,
|
||||
)
|
||||
if isinstance(
|
||||
|
||||
@@ -231,3 +231,10 @@ class ResponseValidationError(ValidationException):
|
||||
) -> None:
|
||||
super().__init__(errors, endpoint_ctx=endpoint_ctx)
|
||||
self.body = body
|
||||
|
||||
|
||||
class FastAPIDeprecationWarning(UserWarning):
|
||||
"""
|
||||
A custom deprecation warning as DeprecationWarning is ignored
|
||||
Ref: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries
|
||||
"""
|
||||
|
||||
@@ -23,6 +23,7 @@ from fastapi.dependencies.utils import (
|
||||
get_validation_alias,
|
||||
)
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX
|
||||
from fastapi.openapi.models import OpenAPI
|
||||
from fastapi.params import Body, ParamTypes
|
||||
@@ -215,9 +216,9 @@ def generate_operation_id(
|
||||
*, route: routing.APIRoute, method: str
|
||||
) -> str: # pragma: nocover
|
||||
warnings.warn(
|
||||
"fastapi.openapi.utils.generate_operation_id() was deprecated, "
|
||||
message="fastapi.openapi.utils.generate_operation_id() was deprecated, "
|
||||
"it is not used internally, and will be removed soon",
|
||||
DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
if route.operation_id:
|
||||
|
||||
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Annotated, Any, Callable, Optional, Union
|
||||
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.openapi.models import Example
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Literal, deprecated
|
||||
@@ -75,7 +76,7 @@ class Param(FieldInfo): # type: ignore[misc]
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
@@ -105,7 +106,7 @@ class Param(FieldInfo): # type: ignore[misc]
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
@@ -530,7 +531,7 @@ class Body(FieldInfo): # type: ignore[misc]
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
@@ -560,7 +561,7 @@ class Body(FieldInfo): # type: ignore[misc]
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
|
||||
@@ -47,6 +47,7 @@ from fastapi.dependencies.utils import (
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.exceptions import (
|
||||
EndpointContext,
|
||||
FastAPIDeprecationWarning,
|
||||
FastAPIError,
|
||||
RequestValidationError,
|
||||
ResponseValidationError,
|
||||
@@ -640,7 +641,7 @@ class APIRoute(routing.Route):
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" Please update the response model {self.response_model!r}.",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.response_field = create_model_field(
|
||||
@@ -680,7 +681,7 @@ class APIRoute(routing.Route):
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" In responses={{}}, please update {model}.",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
response_field = create_model_field(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import warnings
|
||||
from typing import Annotated, Any, Callable, Optional, Union
|
||||
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.openapi.models import Example
|
||||
from fastapi.params import ParamTypes
|
||||
from typing_extensions import deprecated
|
||||
@@ -63,7 +64,7 @@ class Param(FieldInfo):
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
@@ -93,7 +94,7 @@ class Param(FieldInfo):
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
@@ -503,7 +504,7 @@ class Body(FieldInfo):
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
@@ -533,7 +534,7 @@ class Body(FieldInfo):
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
|
||||
@@ -23,6 +23,7 @@ from fastapi._compat import (
|
||||
may_v1,
|
||||
)
|
||||
from fastapi.datastructures import DefaultPlaceholder, DefaultType
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from pydantic import BaseModel
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Literal
|
||||
@@ -195,9 +196,9 @@ def generate_operation_id_for_path(
|
||||
*, name: str, path: str, method: str
|
||||
) -> str: # pragma: nocover
|
||||
warnings.warn(
|
||||
"fastapi.utils.generate_operation_id_for_path() was deprecated, "
|
||||
message="fastapi.utils.generate_operation_id_for_path() was deprecated, "
|
||||
"it is not used internally, and will be removed soon",
|
||||
DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
operation_id = f"{name}{path}"
|
||||
|
||||
@@ -196,6 +196,17 @@ dynamic_context = "test_function"
|
||||
omit = [
|
||||
"docs_src/response_model/tutorial003_04_py39.py",
|
||||
"docs_src/response_model/tutorial003_04_py310.py",
|
||||
"docs_src/dependencies/tutorial008_an_py39.py", # difficult to mock
|
||||
"docs_src/dependencies/tutorial013_an_py310.py", # temporary code example?
|
||||
"docs_src/dependencies/tutorial014_an_py310.py", # temporary code example?
|
||||
# Pydantic V1
|
||||
"docs_src/schema_extra_example/tutorial001_pv1_py310.py",
|
||||
"docs_src/query_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/query_param_models/tutorial002_pv1_an_py310.py",
|
||||
"docs_src/header_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/header_param_models/tutorial002_pv1_an_py310.py",
|
||||
"docs_src/cookie_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/cookie_param_models/tutorial002_pv1_an_py310.py",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
|
||||
@@ -6,6 +6,7 @@ mypy ==1.14.1
|
||||
dirty-equals ==0.9.0
|
||||
sqlmodel==0.0.27
|
||||
flask >=1.1.2,<4.0.0
|
||||
strawberry-graphql >=0.200.0,< 1.0.0
|
||||
anyio[trio] >=3.2.1,<5.0.0
|
||||
PyJWT==2.9.0
|
||||
pyyaml >=5.3.1,<7.0.0
|
||||
|
||||
@@ -6,6 +6,7 @@ from typing import Annotated, Any
|
||||
|
||||
import pytest
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
if "--codspeed" not in sys.argv:
|
||||
@@ -89,7 +90,7 @@ def app(basemodel_class: type[Any]) -> FastAPI:
|
||||
warnings.filterwarnings(
|
||||
"ignore",
|
||||
message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*",
|
||||
category=DeprecationWarning,
|
||||
category=FastAPIDeprecationWarning,
|
||||
)
|
||||
|
||||
@app.post("/sync/validated", response_model=ItemOut)
|
||||
|
||||
@@ -3,6 +3,7 @@ import warnings
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
|
||||
from tests.utils import skip_module_if_py_gte_314
|
||||
|
||||
@@ -504,23 +505,23 @@ def test_body_repr():
|
||||
|
||||
# Deprecation warning tests for regex parameter
|
||||
def test_query_regex_deprecation_warning():
|
||||
with pytest.warns(DeprecationWarning, match="`regex` has been deprecated"):
|
||||
with pytest.warns(FastAPIDeprecationWarning, match="`regex` has been deprecated"):
|
||||
Query(regex="^test$")
|
||||
|
||||
|
||||
def test_body_regex_deprecation_warning():
|
||||
with pytest.warns(DeprecationWarning, match="`regex` has been deprecated"):
|
||||
with pytest.warns(FastAPIDeprecationWarning, match="`regex` has been deprecated"):
|
||||
Body(regex="^test$")
|
||||
|
||||
|
||||
# Deprecation warning tests for example parameter
|
||||
def test_query_example_deprecation_warning():
|
||||
with pytest.warns(DeprecationWarning, match="`example` has been deprecated"):
|
||||
with pytest.warns(FastAPIDeprecationWarning, match="`example` has been deprecated"):
|
||||
Query(example="test example")
|
||||
|
||||
|
||||
def test_body_example_deprecation_warning():
|
||||
with pytest.warns(DeprecationWarning, match="`example` has been deprecated"):
|
||||
with pytest.warns(FastAPIDeprecationWarning, match="`example` has been deprecated"):
|
||||
Body(example={"test": "example"})
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user