From ec464f0938a7c623d3acad1eb8ca0b069cf799d2 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Sun, 18 Feb 2024 13:18:33 +0100 Subject: [PATCH 01/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/newsletter.md`=20(#10853)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/newsletter.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/de/docs/newsletter.md diff --git a/docs/de/docs/newsletter.md b/docs/de/docs/newsletter.md new file mode 100644 index 000000000..31995b164 --- /dev/null +++ b/docs/de/docs/newsletter.md @@ -0,0 +1,5 @@ +# FastAPI und Freunde Newsletter + + + + From 122713b168f0538eba33f0ad4a921e9409ff5055 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 18 Feb 2024 12:18:59 +0000 Subject: [PATCH 02/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 6a366b06c..5ee0017a2 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/newsletter.md`. PR [#10853](https://github.com/tiangolo/fastapi/pull/10853) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Traditional Chinese translation for `docs/zh-hant/docs/learn/index.md`. PR [#11142](https://github.com/tiangolo/fastapi/pull/11142) by [@hsuanchi](https://github.com/hsuanchi). * 🌐 Add Korean translation for `/docs/ko/docs/tutorial/dependencies/global-dependencies.md`. PR [#11123](https://github.com/tiangolo/fastapi/pull/11123) by [@riroan](https://github.com/riroan). * 🌐 Add Korean translation for `/docs/ko/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md`. PR [#11124](https://github.com/tiangolo/fastapi/pull/11124) by [@riroan](https://github.com/riroan). From 73ca60c273977e98a7632871653e3c0ad3dad4f8 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Sun, 18 Feb 2024 13:19:32 +0100 Subject: [PATCH 03/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/fastapi.md`=20(#10813)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/fastapi.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/de/docs/reference/fastapi.md diff --git a/docs/de/docs/reference/fastapi.md b/docs/de/docs/reference/fastapi.md new file mode 100644 index 000000000..4e6a56971 --- /dev/null +++ b/docs/de/docs/reference/fastapi.md @@ -0,0 +1,31 @@ +# `FastAPI`-Klasse + +Hier sind die Referenzinformationen für die Klasse `FastAPI` mit all ihren Parametern, Attributen und Methoden. + +Sie können die `FastAPI`-Klasse direkt von `fastapi` importieren: + +```python +from fastapi import FastAPI +``` + +::: fastapi.FastAPI + options: + members: + - openapi_version + - webhooks + - state + - dependency_overrides + - openapi + - websocket + - include_router + - get + - put + - post + - delete + - options + - head + - patch + - trace + - on_event + - middleware + - exception_handler From 7ca6f1cd1aeb3f148df22af9375069cc82f3c06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emirhan=20Soyta=C5=9F?= Date: Sun, 18 Feb 2024 15:20:41 +0300 Subject: [PATCH 04/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20Turkish=20translatio?= =?UTF-8?q?n=20for=20`docs/tr/docs/tutorial/query-params.md`=20(#11078)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tr/docs/tutorial/query-params.md | 227 ++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 docs/tr/docs/tutorial/query-params.md diff --git a/docs/tr/docs/tutorial/query-params.md b/docs/tr/docs/tutorial/query-params.md new file mode 100644 index 000000000..61232d5b3 --- /dev/null +++ b/docs/tr/docs/tutorial/query-params.md @@ -0,0 +1,227 @@ +# Sorgu Parametreleri + +Fonksiyonda yol parametrelerinin parçası olmayan diğer tanımlamalar otomatik olarak "sorgu" parametresi olarak yorumlanır. + +```Python hl_lines="9" +{!../../../docs_src/query_params/tutorial001.py!} +``` + +Sorgu, bağlantıdaki `?` kısmından sonra gelen ve `&` işareti ile ayrılan anahtar-değer çiftlerinin oluşturduğu bir kümedir. + +Örneğin, aşağıdaki bağlantıda: + +``` +http://127.0.0.1:8000/items/?skip=0&limit=10 +``` + +...sorgu parametreleri şunlardır: + +* `skip`: değeri `0`'dır +* `limit`: değeri `10`'dır + +Parametreler bağlantının bir parçası oldukları için doğal olarak string olarak değerlendirilirler. + +Fakat, Python tipleri ile tanımlandıkları zaman (yukarıdaki örnekte `int` oldukları gibi), parametreler o tiplere dönüştürülür ve o tipler çerçevesinde doğrulanırlar. + +Yol parametreleri için geçerli olan her türlü işlem aynı şekilde sorgu parametreleri için de geçerlidir: + +* Editör desteği (şüphesiz) +* Veri "ayrıştırma" +* Veri doğrulama +* Otomatik dokümantasyon + +## Varsayılanlar + +Sorgu parametreleri, adres yolunun sabit bir parçası olmadıklarından dolayı isteğe bağlı ve varsayılan değere sahip olabilirler. + +Yukarıdaki örnekte `skip=0` ve `limit=10` varsayılan değere sahiplerdir. + +Yani, aşağıdaki bağlantıya gitmek: + +``` +http://127.0.0.1:8000/items/ +``` + +şu adrese gitmek ile aynı etkiye sahiptir: + +``` +http://127.0.0.1:8000/items/?skip=0&limit=10 +``` + +Ancak, mesela şöyle bir adresi ziyaret ederseniz: + +``` +http://127.0.0.1:8000/items/?skip=20 +``` + +Fonksiyonunuzdaki parametre değerleri aşağıdaki gibi olacaktır: + +* `skip=20`: çünkü bağlantıda böyle tanımlandı. +* `limit=10`: çünkü varsayılan değer buydu. + +## İsteğe Bağlı Parametreler + +Aynı şekilde, varsayılan değerlerini `None` olarak atayarak isteğe bağlı parametreler tanımlayabilirsiniz: + +=== "Python 3.10+" + + ```Python hl_lines="7" + {!> ../../../docs_src/query_params/tutorial002_py310.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="9" + {!> ../../../docs_src/query_params/tutorial002.py!} + ``` + +Bu durumda, `q` fonksiyon parametresi isteğe bağlı olacak ve varsayılan değer olarak `None` alacaktır. + +!!! check "Ek bilgi" + Ayrıca, dikkatinizi çekerim ki; **FastAPI**, `item_id` parametresinin bir yol parametresi olduğunu ve `q` parametresinin yol değil bir sorgu parametresi olduğunu fark edecek kadar beceriklidir. + +## Sorgu Parametresi Tip Dönüşümü + +Aşağıda görüldüğü gibi dönüştürülmek üzere `bool` tipleri de tanımlayabilirsiniz: + +=== "Python 3.10+" + + ```Python hl_lines="7" + {!> ../../../docs_src/query_params/tutorial003_py310.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="9" + {!> ../../../docs_src/query_params/tutorial003.py!} + ``` + +Bu durumda, eğer şu adrese giderseniz: + +``` +http://127.0.0.1:8000/items/foo?short=1 +``` + +veya + +``` +http://127.0.0.1:8000/items/foo?short=True +``` + +veya + +``` +http://127.0.0.1:8000/items/foo?short=true +``` + +veya + +``` +http://127.0.0.1:8000/items/foo?short=on +``` + +veya + +``` +http://127.0.0.1:8000/items/foo?short=yes +``` + +veya adres, herhangi farklı bir harf varyasyonu içermesi durumuna rağmen (büyük harf, sadece baş harfi büyük kelime, vb.) fonksiyonunuz, `bool` tipli `short` parametresini `True` olarak algılayacaktır. Aksi halde `False` olarak algılanacaktır. + + +## Çoklu Yol ve Sorgu Parametreleri + +**FastAPI** neyin ne olduğunu ayırt edebileceğinden dolayı aynı anda birden fazla yol ve sorgu parametresi tanımlayabilirsiniz. + +Ve parametreleri, herhangi bir sıraya koymanıza da gerek yoktur. + +İsimlerine göre belirleneceklerdir: + +=== "Python 3.10+" + + ```Python hl_lines="6 8" + {!> ../../../docs_src/query_params/tutorial004_py310.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="8 10" + {!> ../../../docs_src/query_params/tutorial004.py!} + ``` + +## Zorunlu Sorgu Parametreleri + +Türü yol olmayan bir parametre (şu ana kadar sadece sorgu parametrelerini gördük) için varsayılan değer tanımlarsanız o parametre zorunlu olmayacaktır. + +Parametre için belirli bir değer atamak istemeyip parametrenin sadece isteğe bağlı olmasını istiyorsanız değerini `None` olarak atayabilirsiniz. + +Fakat, bir sorgu parametresini zorunlu yapmak istiyorsanız varsayılan bir değer atamamanız yeterli olacaktır: + +```Python hl_lines="6-7" +{!../../../docs_src/query_params/tutorial005.py!} +``` + +Burada `needy` parametresi `str` tipinden oluşan zorunlu bir sorgu parametresidir. + +Eğer tarayıcınızda şu bağlantıyı: + +``` +http://127.0.0.1:8000/items/foo-item +``` + +...`needy` parametresini eklemeden açarsanız şuna benzer bir hata ile karşılaşırsınız: + +```JSON +{ + "detail": [ + { + "type": "missing", + "loc": [ + "query", + "needy" + ], + "msg": "Field required", + "input": null, + "url": "https://errors.pydantic.dev/2.1/v/missing" + } + ] +} +``` + +`needy` zorunlu bir parametre olduğundan dolayı bağlantıda tanımlanması gerekir: + +``` +http://127.0.0.1:8000/items/foo-item?needy=sooooneedy +``` + +...bu iş görür: + +```JSON +{ + "item_id": "foo-item", + "needy": "sooooneedy" +} +``` + +Ve elbette, bazı parametreleri zorunlu, bazılarını varsayılan değerli ve bazılarını tamamen opsiyonel olarak tanımlayabilirsiniz: + +=== "Python 3.10+" + + ```Python hl_lines="8" + {!> ../../../docs_src/query_params/tutorial006_py310.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="10" + {!> ../../../docs_src/query_params/tutorial006.py!} + ``` + +Bu durumda, 3 tane sorgu parametresi var olacaktır: + +* `needy`, zorunlu bir `str`. +* `skip`, varsayılan değeri `0` olan bir `int`. +* `limit`, isteğe bağlı bir `int`. + +!!! tip "İpucu" + Ayrıca, [Yol Parametreleri](path-params.md#predefined-values){.internal-link target=_blank}nde de kullanıldığı şekilde `Enum` sınıfından faydalanabilirsiniz. From f1ff930e6828088cd39b0045af0110bba410f73e Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 18 Feb 2024 12:20:55 +0000 Subject: [PATCH 05/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 5ee0017a2..b23e0c897 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/fastapi.md`. PR [#10813](https://github.com/tiangolo/fastapi/pull/10813) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/newsletter.md`. PR [#10853](https://github.com/tiangolo/fastapi/pull/10853) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Traditional Chinese translation for `docs/zh-hant/docs/learn/index.md`. PR [#11142](https://github.com/tiangolo/fastapi/pull/11142) by [@hsuanchi](https://github.com/hsuanchi). * 🌐 Add Korean translation for `/docs/ko/docs/tutorial/dependencies/global-dependencies.md`. PR [#11123](https://github.com/tiangolo/fastapi/pull/11123) by [@riroan](https://github.com/riroan). From 3808d618fdebdd54840e8b8ba5252d4c2edb4c64 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 18 Feb 2024 12:21:32 +0000 Subject: [PATCH 06/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index b23e0c897..98fea7bb4 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11078](https://github.com/tiangolo/fastapi/pull/11078) by [@emrhnsyts](https://github.com/emrhnsyts). * 🌐 Add German translation for `docs/de/docs/reference/fastapi.md`. PR [#10813](https://github.com/tiangolo/fastapi/pull/10813) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/newsletter.md`. PR [#10853](https://github.com/tiangolo/fastapi/pull/10853) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Traditional Chinese translation for `docs/zh-hant/docs/learn/index.md`. PR [#11142](https://github.com/tiangolo/fastapi/pull/11142) by [@hsuanchi](https://github.com/hsuanchi). From 6062ec86f3039f044a9bafa637b2544947c12afc Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Mon, 19 Feb 2024 16:53:18 +0100 Subject: [PATCH 07/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/request.md`=20(#10821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/request.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/de/docs/reference/request.md diff --git a/docs/de/docs/reference/request.md b/docs/de/docs/reference/request.md new file mode 100644 index 000000000..b170c1e40 --- /dev/null +++ b/docs/de/docs/reference/request.md @@ -0,0 +1,14 @@ +# `Request`-Klasse + +Sie können einen Parameter in einer *Pfadoperation-Funktion* oder einer Abhängigkeit als vom Typ `Request` deklarieren und dann direkt auf das Requestobjekt zugreifen, ohne jegliche Validierung, usw. + +Sie können es direkt von `fastapi` importieren: + +```python +from fastapi import Request +``` + +!!! tip "Tipp" + Wenn Sie Abhängigkeiten definieren möchten, die sowohl mit HTTP als auch mit WebSockets kompatibel sein sollen, können Sie einen Parameter definieren, der eine `HTTPConnection` anstelle eines `Request` oder eines `WebSocket` akzeptiert. + +::: fastapi.Request From 646e7eb3c7cc28572fbf3183b8784077a652e2c6 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Mon, 19 Feb 2024 16:53:39 +0100 Subject: [PATCH 08/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/responses.md`=20(#10825)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/responses.md | 164 ++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 docs/de/docs/reference/responses.md diff --git a/docs/de/docs/reference/responses.md b/docs/de/docs/reference/responses.md new file mode 100644 index 000000000..c0e9f07e7 --- /dev/null +++ b/docs/de/docs/reference/responses.md @@ -0,0 +1,164 @@ +# Benutzerdefinierte Responseklassen – File, HTML, Redirect, Streaming, usw. + +Es gibt mehrere benutzerdefinierte Responseklassen, von denen Sie eine Instanz erstellen und diese direkt von Ihren *Pfadoperationen* zurückgeben können. + +Lesen Sie mehr darüber in der [FastAPI-Dokumentation zu benutzerdefinierten Responses – HTML, Stream, Datei, andere](../advanced/custom-response.md). + +Sie können diese direkt von `fastapi.responses` importieren: + +```python +from fastapi.responses import ( + FileResponse, + HTMLResponse, + JSONResponse, + ORJSONResponse, + PlainTextResponse, + RedirectResponse, + Response, + StreamingResponse, + UJSONResponse, +) +``` + +## FastAPI-Responses + +Es gibt einige benutzerdefinierte FastAPI-Responseklassen, welche Sie verwenden können, um die JSON-Performanz zu optimieren. + +::: fastapi.responses.UJSONResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.ORJSONResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +## Starlette-Responses + +::: fastapi.responses.FileResponse + options: + members: + - chunk_size + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.HTMLResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.JSONResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.PlainTextResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.RedirectResponse + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.Response + options: + members: + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie + +::: fastapi.responses.StreamingResponse + options: + members: + - body_iterator + - charset + - status_code + - media_type + - body + - background + - raw_headers + - render + - init_headers + - headers + - set_cookie + - delete_cookie From ce1a358cbf2567012c7f85ab8b941752b1f95a39 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 19 Feb 2024 15:53:44 +0000 Subject: [PATCH 09/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 98fea7bb4..833dad61f 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/request.md`. PR [#10821](https://github.com/tiangolo/fastapi/pull/10821) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11078](https://github.com/tiangolo/fastapi/pull/11078) by [@emrhnsyts](https://github.com/emrhnsyts). * 🌐 Add German translation for `docs/de/docs/reference/fastapi.md`. PR [#10813](https://github.com/tiangolo/fastapi/pull/10813) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/newsletter.md`. PR [#10853](https://github.com/tiangolo/fastapi/pull/10853) by [@nilslindemann](https://github.com/nilslindemann). From d0b143916ca1bb83e0cff25b7f36e7a0bf003ae3 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 19 Feb 2024 15:54:37 +0000 Subject: [PATCH 10/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 833dad61f..2c25f82ae 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/responses.md`. PR [#10825](https://github.com/tiangolo/fastapi/pull/10825) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/request.md`. PR [#10821](https://github.com/tiangolo/fastapi/pull/10821) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11078](https://github.com/tiangolo/fastapi/pull/11078) by [@emrhnsyts](https://github.com/emrhnsyts). * 🌐 Add German translation for `docs/de/docs/reference/fastapi.md`. PR [#10813](https://github.com/tiangolo/fastapi/pull/10813) by [@nilslindemann](https://github.com/nilslindemann). From 073a05ebdd395bea1317c3a52e9a40c7fd45df64 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Mon, 19 Feb 2024 16:54:52 +0100 Subject: [PATCH 11/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/encoders.md`=20(#10840)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/encoders.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/de/docs/reference/encoders.md diff --git a/docs/de/docs/reference/encoders.md b/docs/de/docs/reference/encoders.md new file mode 100644 index 000000000..2489b8c60 --- /dev/null +++ b/docs/de/docs/reference/encoders.md @@ -0,0 +1,3 @@ +# Encoder – `jsonable_encoder` + +::: fastapi.encoders.jsonable_encoder From e76977bb3575547f1229a8b319724593302cefb5 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 19 Feb 2024 15:57:07 +0000 Subject: [PATCH 12/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 2c25f82ae..a02bf2a1d 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/encoders.md`. PR [#10840](https://github.com/tiangolo/fastapi/pull/10840) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/responses.md`. PR [#10825](https://github.com/tiangolo/fastapi/pull/10825) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/request.md`. PR [#10821](https://github.com/tiangolo/fastapi/pull/10821) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11078](https://github.com/tiangolo/fastapi/pull/11078) by [@emrhnsyts](https://github.com/emrhnsyts). From e52bf9628f270a7e7c6fba2a99925d6e53cb30b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Sezer=20Ta=C5=9Fan?= <13135006+hasansezertasan@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:46:02 +0300 Subject: [PATCH 13/29] =?UTF-8?q?=F0=9F=8C=90=20Update=20Turkish=20transla?= =?UTF-8?q?tion=20for=20`docs/tr/docs/tutorial/query-params.md`=20(#11162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tr/docs/tutorial/query-params.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tr/docs/tutorial/query-params.md b/docs/tr/docs/tutorial/query-params.md index 61232d5b3..aa3915557 100644 --- a/docs/tr/docs/tutorial/query-params.md +++ b/docs/tr/docs/tutorial/query-params.md @@ -224,4 +224,4 @@ Bu durumda, 3 tane sorgu parametresi var olacaktır: * `limit`, isteğe bağlı bir `int`. !!! tip "İpucu" - Ayrıca, [Yol Parametreleri](path-params.md#predefined-values){.internal-link target=_blank}nde de kullanıldığı şekilde `Enum` sınıfından faydalanabilirsiniz. + Ayrıca, [Yol Parametrelerinde](path-params.md#predefined-values){.internal-link target=_blank} de kullanıldığı şekilde `Enum` sınıfından faydalanabilirsiniz. From a6bc32a61a2f57645d5535d076e38b0b3eb4138d Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 19 Feb 2024 18:46:23 +0000 Subject: [PATCH 14/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index a02bf2a1d..d98faea4d 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Update Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11162](https://github.com/tiangolo/fastapi/pull/11162) by [@hasansezertasan](https://github.com/hasansezertasan). * 🌐 Add German translation for `docs/de/docs/reference/encoders.md`. PR [#10840](https://github.com/tiangolo/fastapi/pull/10840) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/responses.md`. PR [#10825](https://github.com/tiangolo/fastapi/pull/10825) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/request.md`. PR [#10821](https://github.com/tiangolo/fastapi/pull/10821) by [@nilslindemann](https://github.com/nilslindemann). From 626b066e56e39162f328431395856c959d150bc4 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Wed, 21 Feb 2024 23:23:00 +0100 Subject: [PATCH 15/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/external-links.md`=20(#10852)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/external-links.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/de/docs/external-links.md diff --git a/docs/de/docs/external-links.md b/docs/de/docs/external-links.md new file mode 100644 index 000000000..d97f4d39c --- /dev/null +++ b/docs/de/docs/external-links.md @@ -0,0 +1,36 @@ +# Externe Links und Artikel + +**FastAPI** hat eine großartige Community, die ständig wächst. + +Es gibt viele Beiträge, Artikel, Tools und Projekte zum Thema **FastAPI**. + +Hier ist eine unvollständige Liste einiger davon. + +!!! tip "Tipp" + Wenn Sie einen Artikel, ein Projekt, ein Tool oder irgendetwas im Zusammenhang mit **FastAPI** haben, was hier noch nicht aufgeführt ist, erstellen Sie einen Pull Request und fügen Sie es hinzu. + +!!! note "Hinweis Deutsche Übersetzung" + Die folgenden Überschriften und Links werden aus einer anderen Datei gelesen und sind daher nicht ins Deutsche übersetzt. + +{% for section_name, section_content in external_links.items() %} + +## {{ section_name }} + +{% for lang_name, lang_content in section_content.items() %} + +### {{ lang_name }} + +{% for item in lang_content %} + +* {{ item.title }} by {{ item.author }}. + +{% endfor %} +{% endfor %} +{% endfor %} + +## Projekte + +Die neuesten GitHub-Projekte zum Thema `fastapi`: + +
+
From 5da35ff980a9477675929ddc0643e7eb27ea6208 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 21 Feb 2024 22:23:21 +0000 Subject: [PATCH 16/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index d98faea4d..d8d87ca46 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/external-links.md`. PR [#10852](https://github.com/tiangolo/fastapi/pull/10852) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Update Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11162](https://github.com/tiangolo/fastapi/pull/11162) by [@hasansezertasan](https://github.com/hasansezertasan). * 🌐 Add German translation for `docs/de/docs/reference/encoders.md`. PR [#10840](https://github.com/tiangolo/fastapi/pull/10840) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/responses.md`. PR [#10825](https://github.com/tiangolo/fastapi/pull/10825) by [@nilslindemann](https://github.com/nilslindemann). From dec45c534f97bb5635492cba78a93f1409ec6b2a Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Wed, 21 Feb 2024 23:26:02 +0100 Subject: [PATCH 17/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/templating.md`=20(#10842)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/templating.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/de/docs/reference/templating.md diff --git a/docs/de/docs/reference/templating.md b/docs/de/docs/reference/templating.md new file mode 100644 index 000000000..c367a0179 --- /dev/null +++ b/docs/de/docs/reference/templating.md @@ -0,0 +1,13 @@ +# Templating – `Jinja2Templates` + +Sie können die `Jinja2Templates`-Klasse verwenden, um Jinja-Templates zu rendern. + +Lesen Sie mehr darüber in der [FastAPI-Dokumentation zu Templates](../advanced/templates.md). + +Sie können die Klasse direkt von `fastapi.templating` importieren: + +```python +from fastapi.templating import Jinja2Templates +``` + +::: fastapi.templating.Jinja2Templates From 9210e6a330bc9639fcb3315a493e39aa2119d142 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Wed, 21 Feb 2024 23:26:48 +0100 Subject: [PATCH 18/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20German=20translation?= =?UTF-8?q?=20for=20`docs/de/docs/reference/background.md`=20(#10820)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/de/docs/reference/background.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/de/docs/reference/background.md diff --git a/docs/de/docs/reference/background.md b/docs/de/docs/reference/background.md new file mode 100644 index 000000000..0fd389325 --- /dev/null +++ b/docs/de/docs/reference/background.md @@ -0,0 +1,11 @@ +# Hintergrundtasks – `BackgroundTasks` + +Sie können einen Parameter in einer *Pfadoperation-Funktion* oder einer Abhängigkeitsfunktion mit dem Typ `BackgroundTasks` deklarieren und diesen danach verwenden, um die Ausführung von Hintergrundtasks nach dem Senden der Response zu definieren. + +Sie können `BackgroundTasks` direkt von `fastapi` importieren: + +```python +from fastapi import BackgroundTasks +``` + +::: fastapi.BackgroundTasks From cb938740145c5d0cea78a26bc0a7215aae4506b9 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 21 Feb 2024 22:27:17 +0000 Subject: [PATCH 19/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index d8d87ca46..7251a4f91 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/templating.md`. PR [#10842](https://github.com/tiangolo/fastapi/pull/10842) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/external-links.md`. PR [#10852](https://github.com/tiangolo/fastapi/pull/10852) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Update Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11162](https://github.com/tiangolo/fastapi/pull/11162) by [@hasansezertasan](https://github.com/hasansezertasan). * 🌐 Add German translation for `docs/de/docs/reference/encoders.md`. PR [#10840](https://github.com/tiangolo/fastapi/pull/10840) by [@nilslindemann](https://github.com/nilslindemann). From 6336604906d50e0aca978d15ef82236bac23fb15 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 21 Feb 2024 22:27:53 +0000 Subject: [PATCH 20/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 7251a4f91..e595ed927 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -14,6 +14,7 @@ hide: ### Translations +* 🌐 Add German translation for `docs/de/docs/reference/background.md`. PR [#10820](https://github.com/tiangolo/fastapi/pull/10820) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/reference/templating.md`. PR [#10842](https://github.com/tiangolo/fastapi/pull/10842) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Add German translation for `docs/de/docs/external-links.md`. PR [#10852](https://github.com/tiangolo/fastapi/pull/10852) by [@nilslindemann](https://github.com/nilslindemann). * 🌐 Update Turkish translation for `docs/tr/docs/tutorial/query-params.md`. PR [#11162](https://github.com/tiangolo/fastapi/pull/11162) by [@hasansezertasan](https://github.com/hasansezertasan). From bf771bd7817f8e8348f85836a21d1e96c0b4f7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 25 Feb 2024 00:06:37 +0100 Subject: [PATCH 21/29] =?UTF-8?q?=F0=9F=90=9B=20Fix=20unhandled=20growing?= =?UTF-8?q?=20memory=20for=20internal=20server=20errors,=20refactor=20depe?= =?UTF-8?q?ndencies=20with=20`yield`=20and=20`except`=20to=20require=20rai?= =?UTF-8?q?sing=20again=20as=20in=20regular=20Python=20(#11191)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../dependencies/dependencies-with-yield.md | 70 +++++++++++- docs_src/dependencies/tutorial008c.py | 27 +++++ docs_src/dependencies/tutorial008c_an.py | 28 +++++ docs_src/dependencies/tutorial008c_an_py39.py | 29 +++++ docs_src/dependencies/tutorial008d.py | 28 +++++ docs_src/dependencies/tutorial008d_an.py | 29 +++++ docs_src/dependencies/tutorial008d_an_py39.py | 30 +++++ fastapi/routing.py | 108 ++++++++---------- tests/test_dependency_contextmanager.py | 2 + tests/test_dependency_normal_exceptions.py | 1 + .../test_tutorial008b_an_py39.py | 20 +++- .../test_dependencies/test_tutorial008c.py | 38 ++++++ .../test_dependencies/test_tutorial008c_an.py | 38 ++++++ .../test_tutorial008c_an_py39.py | 44 +++++++ .../test_dependencies/test_tutorial008d.py | 41 +++++++ .../test_dependencies/test_tutorial008d_an.py | 41 +++++++ .../test_tutorial008d_an_py39.py | 47 ++++++++ 17 files changed, 553 insertions(+), 68 deletions(-) create mode 100644 docs_src/dependencies/tutorial008c.py create mode 100644 docs_src/dependencies/tutorial008c_an.py create mode 100644 docs_src/dependencies/tutorial008c_an_py39.py create mode 100644 docs_src/dependencies/tutorial008d.py create mode 100644 docs_src/dependencies/tutorial008d_an.py create mode 100644 docs_src/dependencies/tutorial008d_an_py39.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008c.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008c_an.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008d.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008d_an.py create mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py diff --git a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md index de87ba315..ad5aed932 100644 --- a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md +++ b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md @@ -162,6 +162,63 @@ The same way, you could raise an `HTTPException` or similar in the exit code, af An alternative you could use to catch exceptions (and possibly also raise another `HTTPException`) is to create a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}. +## Dependencies with `yield` and `except` + +If you catch an exception using `except` in a dependency with `yield` and you don't raise it again (or raise a new exception), FastAPI won't be able to notice there was an exception, the same way that would happen with regular Python: + +=== "Python 3.9+" + + ```Python hl_lines="15-16" + {!> ../../../docs_src/dependencies/tutorial008c_an_py39.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="14-15" + {!> ../../../docs_src/dependencies/tutorial008c_an.py!} + ``` + +=== "Python 3.8+ non-Annotated" + + !!! tip + Prefer to use the `Annotated` version if possible. + + ```Python hl_lines="13-14" + {!> ../../../docs_src/dependencies/tutorial008c.py!} + ``` + +In this case, the client will see an *HTTP 500 Internal Server Error* response as it should, given that we are not raising an `HTTPException` or similar, but the server will **not have any logs** or any other indication of what was the error. 😱 + +### Always `raise` in Dependencies with `yield` and `except` + +If you catch an exception in a dependency with `yield`, unless you are raising another `HTTPException` or similar, you should re-raise the original exception. + +You can re-raise the same exception using `raise`: + +=== "Python 3.9+" + + ```Python hl_lines="17" + {!> ../../../docs_src/dependencies/tutorial008d_an_py39.py!} + ``` + +=== "Python 3.8+" + + ```Python hl_lines="16" + {!> ../../../docs_src/dependencies/tutorial008d_an.py!} + ``` + + +=== "Python 3.8+ non-Annotated" + + !!! tip + Prefer to use the `Annotated` version if possible. + + ```Python hl_lines="15" + {!> ../../../docs_src/dependencies/tutorial008d.py!} + ``` + +Now the client will get the same *HTTP 500 Internal Server Error* response, but the server will have our custom `InternalError` in the logs. 😎 + ## Execution of dependencies with `yield` The sequence of execution is more or less like this diagram. Time flows from top to bottom. And each column is one of the parts interacting or executing code. @@ -187,7 +244,6 @@ participant tasks as Background tasks operation -->> dep: Raise Exception (e.g. HTTPException) opt handle dep -->> dep: Can catch exception, raise a new HTTPException, raise other exception - dep -->> handler: Auto forward exception end handler -->> client: HTTP error response end @@ -210,15 +266,23 @@ participant tasks as Background tasks !!! tip This diagram shows `HTTPException`, but you could also raise any other exception that you catch in a dependency with `yield` or with a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}. - If you raise any exception, it will be passed to the dependencies with yield, including `HTTPException`, and then **again** to the exception handlers. If there's no exception handler for that exception, it will then be handled by the default internal `ServerErrorMiddleware`, returning a 500 HTTP status code, to let the client know that there was an error in the server. + If you raise any exception, it will be passed to the dependencies with yield, including `HTTPException`. In most cases you will want to re-raise that same exception or a new one from the dependency with `yield` to make sure it's properly handled. -## Dependencies with `yield`, `HTTPException` and Background Tasks +## Dependencies with `yield`, `HTTPException`, `except` and Background Tasks !!! warning You most probably don't need these technical details, you can skip this section and continue below. These details are useful mainly if you were using a version of FastAPI prior to 0.106.0 and used resources from dependencies with `yield` in background tasks. +### Dependencies with `yield` and `except`, Technical Details + +Before FastAPI 0.110.0, if you used a dependency with `yield`, and then you captured an exception with `except` in that dependency, and you didn't raise the exception again, the exception would be automatically raised/forwarded to any exception handlers or the internal server error handler. + +This was changed in version 0.110.0 to fix unhandled memory consumption from forwarded exceptions without a handler (internal server errors), and to make it consistent with the behavior of regular Python code. + +### Background Tasks and Dependencies with `yield`, Technical Details + Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} would have already run. This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished. diff --git a/docs_src/dependencies/tutorial008c.py b/docs_src/dependencies/tutorial008c.py new file mode 100644 index 000000000..4b99a5a31 --- /dev/null +++ b/docs_src/dependencies/tutorial008c.py @@ -0,0 +1,27 @@ +from fastapi import Depends, FastAPI, HTTPException + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("Oops, we didn't raise again, Britney 😱") + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: str = Depends(get_username)): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/docs_src/dependencies/tutorial008c_an.py b/docs_src/dependencies/tutorial008c_an.py new file mode 100644 index 000000000..94f59f9aa --- /dev/null +++ b/docs_src/dependencies/tutorial008c_an.py @@ -0,0 +1,28 @@ +from fastapi import Depends, FastAPI, HTTPException +from typing_extensions import Annotated + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("Oops, we didn't raise again, Britney 😱") + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/docs_src/dependencies/tutorial008c_an_py39.py b/docs_src/dependencies/tutorial008c_an_py39.py new file mode 100644 index 000000000..da92efa9c --- /dev/null +++ b/docs_src/dependencies/tutorial008c_an_py39.py @@ -0,0 +1,29 @@ +from typing import Annotated + +from fastapi import Depends, FastAPI, HTTPException + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("Oops, we didn't raise again, Britney 😱") + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/docs_src/dependencies/tutorial008d.py b/docs_src/dependencies/tutorial008d.py new file mode 100644 index 000000000..93039343d --- /dev/null +++ b/docs_src/dependencies/tutorial008d.py @@ -0,0 +1,28 @@ +from fastapi import Depends, FastAPI, HTTPException + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("We don't swallow the internal error here, we raise again 😎") + raise + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: str = Depends(get_username)): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/docs_src/dependencies/tutorial008d_an.py b/docs_src/dependencies/tutorial008d_an.py new file mode 100644 index 000000000..c35424574 --- /dev/null +++ b/docs_src/dependencies/tutorial008d_an.py @@ -0,0 +1,29 @@ +from fastapi import Depends, FastAPI, HTTPException +from typing_extensions import Annotated + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("We don't swallow the internal error here, we raise again 😎") + raise + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/docs_src/dependencies/tutorial008d_an_py39.py b/docs_src/dependencies/tutorial008d_an_py39.py new file mode 100644 index 000000000..99bd5cb91 --- /dev/null +++ b/docs_src/dependencies/tutorial008d_an_py39.py @@ -0,0 +1,30 @@ +from typing import Annotated + +from fastapi import Depends, FastAPI, HTTPException + +app = FastAPI() + + +class InternalError(Exception): + pass + + +def get_username(): + try: + yield "Rick" + except InternalError: + print("We don't swallow the internal error here, we raise again 😎") + raise + + +@app.get("/items/{item_id}") +def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): + if item_id == "portal-gun": + raise InternalError( + f"The portal gun is too dangerous to be owned by {username}" + ) + if item_id != "plumbus": + raise HTTPException( + status_code=404, detail="Item not found, there's only a plumbus here" + ) + return item_id diff --git a/fastapi/routing.py b/fastapi/routing.py index acebabfca..23a32d15f 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -216,19 +216,14 @@ def get_request_handler( actual_response_class = response_class async def app(request: Request) -> Response: - exception_to_reraise: Optional[Exception] = None response: Union[Response, None] = None - async with AsyncExitStack() as async_exit_stack: - # TODO: remove this scope later, after a few releases - # This scope fastapi_astack is no longer used by FastAPI, kept for - # compatibility, just in case - request.scope["fastapi_astack"] = async_exit_stack + async with AsyncExitStack() as file_stack: try: body: Any = None if body_field: if is_body_form: body = await request.form() - async_exit_stack.push_async_callback(body.close) + file_stack.push_async_callback(body.close) else: body_bytes = await request.body() if body_bytes: @@ -260,18 +255,17 @@ def get_request_handler( ], body=e.doc, ) - exception_to_reraise = validation_error raise validation_error from e - except HTTPException as e: - exception_to_reraise = e + except HTTPException: + # If a middleware raises an HTTPException, it should be raised again raise except Exception as e: http_error = HTTPException( status_code=400, detail="There was an error parsing the body" ) - exception_to_reraise = http_error raise http_error from e - try: + errors: List[Any] = [] + async with AsyncExitStack() as async_exit_stack: solved_result = await solve_dependencies( request=request, dependant=dependant, @@ -280,59 +274,53 @@ def get_request_handler( async_exit_stack=async_exit_stack, ) values, errors, background_tasks, sub_response, _ = solved_result - except Exception as e: - exception_to_reraise = e - raise e + if not errors: + raw_response = await run_endpoint_function( + dependant=dependant, values=values, is_coroutine=is_coroutine + ) + if isinstance(raw_response, Response): + if raw_response.background is None: + raw_response.background = background_tasks + response = raw_response + else: + response_args: Dict[str, Any] = {"background": background_tasks} + # If status_code was set, use it, otherwise use the default from the + # response class, in the case of redirect it's 307 + current_status_code = ( + status_code if status_code else sub_response.status_code + ) + if current_status_code is not None: + response_args["status_code"] = current_status_code + if sub_response.status_code: + response_args["status_code"] = sub_response.status_code + content = await serialize_response( + field=response_field, + response_content=raw_response, + include=response_model_include, + exclude=response_model_exclude, + by_alias=response_model_by_alias, + exclude_unset=response_model_exclude_unset, + exclude_defaults=response_model_exclude_defaults, + exclude_none=response_model_exclude_none, + is_coroutine=is_coroutine, + ) + response = actual_response_class(content, **response_args) + if not is_body_allowed_for_status_code(response.status_code): + response.body = b"" + response.headers.raw.extend(sub_response.headers.raw) if errors: validation_error = RequestValidationError( _normalize_errors(errors), body=body ) - exception_to_reraise = validation_error raise validation_error - else: - try: - raw_response = await run_endpoint_function( - dependant=dependant, values=values, is_coroutine=is_coroutine - ) - except Exception as e: - exception_to_reraise = e - raise e - if isinstance(raw_response, Response): - if raw_response.background is None: - raw_response.background = background_tasks - response = raw_response - else: - response_args: Dict[str, Any] = {"background": background_tasks} - # If status_code was set, use it, otherwise use the default from the - # response class, in the case of redirect it's 307 - current_status_code = ( - status_code if status_code else sub_response.status_code - ) - if current_status_code is not None: - response_args["status_code"] = current_status_code - if sub_response.status_code: - response_args["status_code"] = sub_response.status_code - content = await serialize_response( - field=response_field, - response_content=raw_response, - include=response_model_include, - exclude=response_model_exclude, - by_alias=response_model_by_alias, - exclude_unset=response_model_exclude_unset, - exclude_defaults=response_model_exclude_defaults, - exclude_none=response_model_exclude_none, - is_coroutine=is_coroutine, - ) - response = actual_response_class(content, **response_args) - if not is_body_allowed_for_status_code(response.status_code): - response.body = b"" - response.headers.raw.extend(sub_response.headers.raw) - # This exception was possibly handled by the dependency but it should - # still bubble up so that the ServerErrorMiddleware can return a 500 - # or the ExceptionMiddleware can catch and handle any other exceptions - if exception_to_reraise: - raise exception_to_reraise - assert response is not None, "An error occurred while generating the request" + if response is None: + raise FastAPIError( + "No response object was returned. There's a high chance that the " + "application code is raising an exception and a dependency with yield " + "has a block with a bare except, or a block with except Exception, " + "and is not raising the exception again. Read more about it in the " + "docs: https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-except" + ) return response return app diff --git a/tests/test_dependency_contextmanager.py b/tests/test_dependency_contextmanager.py index b07f9aa5b..008dab7bc 100644 --- a/tests/test_dependency_contextmanager.py +++ b/tests/test_dependency_contextmanager.py @@ -55,6 +55,7 @@ async def asyncgen_state_try(state: Dict[str, str] = Depends(get_state)): yield state["/async_raise"] except AsyncDependencyError: errors.append("/async_raise") + raise finally: state["/async_raise"] = "asyncgen raise finalized" @@ -65,6 +66,7 @@ def generator_state_try(state: Dict[str, str] = Depends(get_state)): yield state["/sync_raise"] except SyncDependencyError: errors.append("/sync_raise") + raise finally: state["/sync_raise"] = "generator raise finalized" diff --git a/tests/test_dependency_normal_exceptions.py b/tests/test_dependency_normal_exceptions.py index 23c366d5d..326f8fd88 100644 --- a/tests/test_dependency_normal_exceptions.py +++ b/tests/test_dependency_normal_exceptions.py @@ -20,6 +20,7 @@ async def get_database(): fake_database.update(temp_database) except HTTPException: state["except"] = True + raise finally: state["finally"] = True diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py index 7f51fc52a..7d24809a8 100644 --- a/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py +++ b/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py @@ -1,23 +1,33 @@ +import pytest from fastapi.testclient import TestClient -from docs_src.dependencies.tutorial008b_an import app +from ...utils import needs_py39 -client = TestClient(app) +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008b_an_py39 import app -def test_get_no_item(): + client = TestClient(app) + return client + + +@needs_py39 +def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text assert response.json() == {"detail": "Item not found"} -def test_owner_error(): +@needs_py39 +def test_owner_error(client: TestClient): response = client.get("/items/plumbus") assert response.status_code == 400, response.text assert response.json() == {"detail": "Owner error: Rick"} -def test_get_item(): +@needs_py39 +def test_get_item(client: TestClient): response = client.get("/items/portal-gun") assert response.status_code == 200, response.text assert response.json() == {"description": "Gun to create portals", "owner": "Rick"} diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c.py b/tests/test_tutorial/test_dependencies/test_tutorial008c.py new file mode 100644 index 000000000..27be8895a --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008c.py @@ -0,0 +1,38 @@ +import pytest +from fastapi.exceptions import FastAPIError +from fastapi.testclient import TestClient + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008c import app + + client = TestClient(app) + return client + + +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +def test_fastapi_error(client: TestClient): + with pytest.raises(FastAPIError) as exc_info: + client.get("/items/portal-gun") + assert "No response object was returned" in exc_info.value.args[0] + + +def test_internal_server_error(): + from docs_src.dependencies.tutorial008c import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py b/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py new file mode 100644 index 000000000..10fa1ab50 --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py @@ -0,0 +1,38 @@ +import pytest +from fastapi.exceptions import FastAPIError +from fastapi.testclient import TestClient + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008c_an import app + + client = TestClient(app) + return client + + +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +def test_fastapi_error(client: TestClient): + with pytest.raises(FastAPIError) as exc_info: + client.get("/items/portal-gun") + assert "No response object was returned" in exc_info.value.args[0] + + +def test_internal_server_error(): + from docs_src.dependencies.tutorial008c_an import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py new file mode 100644 index 000000000..6c3acff50 --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py @@ -0,0 +1,44 @@ +import pytest +from fastapi.exceptions import FastAPIError +from fastapi.testclient import TestClient + +from ...utils import needs_py39 + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008c_an_py39 import app + + client = TestClient(app) + return client + + +@needs_py39 +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +@needs_py39 +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +@needs_py39 +def test_fastapi_error(client: TestClient): + with pytest.raises(FastAPIError) as exc_info: + client.get("/items/portal-gun") + assert "No response object was returned" in exc_info.value.args[0] + + +@needs_py39 +def test_internal_server_error(): + from docs_src.dependencies.tutorial008c_an_py39 import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d.py b/tests/test_tutorial/test_dependencies/test_tutorial008d.py new file mode 100644 index 000000000..043496112 --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008d.py @@ -0,0 +1,41 @@ +import pytest +from fastapi.testclient import TestClient + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008d import app + + client = TestClient(app) + return client + + +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +def test_internal_error(client: TestClient): + from docs_src.dependencies.tutorial008d import InternalError + + with pytest.raises(InternalError) as exc_info: + client.get("/items/portal-gun") + assert ( + exc_info.value.args[0] == "The portal gun is too dangerous to be owned by Rick" + ) + + +def test_internal_server_error(): + from docs_src.dependencies.tutorial008d import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py b/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py new file mode 100644 index 000000000..f29d8cdbe --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py @@ -0,0 +1,41 @@ +import pytest +from fastapi.testclient import TestClient + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008d_an import app + + client = TestClient(app) + return client + + +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +def test_internal_error(client: TestClient): + from docs_src.dependencies.tutorial008d_an import InternalError + + with pytest.raises(InternalError) as exc_info: + client.get("/items/portal-gun") + assert ( + exc_info.value.args[0] == "The portal gun is too dangerous to be owned by Rick" + ) + + +def test_internal_server_error(): + from docs_src.dependencies.tutorial008d_an import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py new file mode 100644 index 000000000..0a585f4ad --- /dev/null +++ b/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py @@ -0,0 +1,47 @@ +import pytest +from fastapi.testclient import TestClient + +from ...utils import needs_py39 + + +@pytest.fixture(name="client") +def get_client(): + from docs_src.dependencies.tutorial008d_an_py39 import app + + client = TestClient(app) + return client + + +@needs_py39 +def test_get_no_item(client: TestClient): + response = client.get("/items/foo") + assert response.status_code == 404, response.text + assert response.json() == {"detail": "Item not found, there's only a plumbus here"} + + +@needs_py39 +def test_get(client: TestClient): + response = client.get("/items/plumbus") + assert response.status_code == 200, response.text + assert response.json() == "plumbus" + + +@needs_py39 +def test_internal_error(client: TestClient): + from docs_src.dependencies.tutorial008d_an_py39 import InternalError + + with pytest.raises(InternalError) as exc_info: + client.get("/items/portal-gun") + assert ( + exc_info.value.args[0] == "The portal gun is too dangerous to be owned by Rick" + ) + + +@needs_py39 +def test_internal_server_error(): + from docs_src.dependencies.tutorial008d_an_py39 import app + + client = TestClient(app, raise_server_exceptions=False) + response = client.get("/items/portal-gun") + assert response.status_code == 500, response.text + assert response.text == "Internal Server Error" From b6b0f2a7e6690b923957677807c5c6a4ff556422 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 24 Feb 2024 23:06:56 +0000 Subject: [PATCH 22/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index e595ed927..2e8930ea3 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -7,6 +7,10 @@ hide: ## Latest Changes +### Breaking Changes + +* 🐛 Fix unhandled growing memory for internal server errors, refactor dependencies with `yield` and `except` to require raising again as in regular Python. PR [#11191](https://github.com/tiangolo/fastapi/pull/11191) by [@tiangolo](https://github.com/tiangolo). + ### Docs * ✏️ Fix minor typos in `docs/ko/docs/`. PR [#11126](https://github.com/tiangolo/fastapi/pull/11126) by [@KaniKim](https://github.com/KaniKim). From 32b56a8d08aece04d55331142a18f7b2ce580fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 25 Feb 2024 00:18:13 +0100 Subject: [PATCH 23/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 2e8930ea3..c442f1449 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -10,6 +10,29 @@ hide: ### Breaking Changes * 🐛 Fix unhandled growing memory for internal server errors, refactor dependencies with `yield` and `except` to require raising again as in regular Python. PR [#11191](https://github.com/tiangolo/fastapi/pull/11191) by [@tiangolo](https://github.com/tiangolo). + * This is a breaking change (and only slightly) if you used dependencies with `yield`, used `except` in those dependencies, and didn't raise again. + * This was reported internally by [@rushilsrivastava](https://github.com/rushilsrivastava) as a memory leak when the server had unhandled exceptions that would produce internal server errors, the memory allocated before that point would not be released. + * Read the new docs: [Dependencies with `yield` and `except`](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-except). + +In short, if you had dependencies that looked like: + +```Python +def my_dep(): + try: + yield + except SomeException: + pass +``` + +Now you need to make sure you raise again after `except`, just as you would in regular Python: + +```Python +def my_dep(): + try: + yield + except SomeException: + raise +``` ### Docs From e40747f10ae911910e9cb9a9684576f3b21304c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 25 Feb 2024 00:19:38 +0100 Subject: [PATCH 24/29] =?UTF-8?q?=F0=9F=94=96=20Release=20version=200.110.?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 2 ++ fastapi/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index c442f1449..e01c3544f 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -7,6 +7,8 @@ hide: ## Latest Changes +## 0.110.0 + ### Breaking Changes * 🐛 Fix unhandled growing memory for internal server errors, refactor dependencies with `yield` and `except` to require raising again as in regular Python. PR [#11191](https://github.com/tiangolo/fastapi/pull/11191) by [@tiangolo](https://github.com/tiangolo). diff --git a/fastapi/__init__.py b/fastapi/__init__.py index 3458b9e5b..234969256 100644 --- a/fastapi/__init__.py +++ b/fastapi/__init__.py @@ -1,6 +1,6 @@ """FastAPI framework, high performance, easy to learn, fast to code, ready for production""" -__version__ = "0.109.2" +__version__ = "0.110.0" from starlette import status as status From 937378ff054fb760ace3779134b3d6211b825534 Mon Sep 17 00:00:00 2001 From: Vusal Abdullayev Date: Sun, 25 Feb 2024 18:25:12 +0400 Subject: [PATCH 25/29] =?UTF-8?q?=F0=9F=8C=90=20Add=20Azerbaijani=20transl?= =?UTF-8?q?ation=20for=20`docs/az/learn/index.md`=20(#11192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/az/learn/index.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/az/learn/index.md diff --git a/docs/az/learn/index.md b/docs/az/learn/index.md new file mode 100644 index 000000000..cc32108bf --- /dev/null +++ b/docs/az/learn/index.md @@ -0,0 +1,5 @@ +# Öyrən + +Burada **FastAPI** öyrənmək üçün giriş bölmələri və dərsliklər yer alır. + +Siz bunu kitab, kurs, FastAPI öyrənmək üçün rəsmi və tövsiyə olunan üsul hesab edə bilərsiniz. 😎 From 7ef0b08897afa0972c7e8418d05a0ad654e45996 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 25 Feb 2024 14:25:31 +0000 Subject: [PATCH 26/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index e01c3544f..2d5ab2d9c 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -7,6 +7,10 @@ hide: ## Latest Changes +### Translations + +* 🌐 Add Azerbaijani translation for `docs/az/learn/index.md`. PR [#11192](https://github.com/tiangolo/fastapi/pull/11192) by [@vusallyv](https://github.com/vusallyv). + ## 0.110.0 ### Breaking Changes From c4c70fd7927dbd7d23894f1a69d42457fb7cadbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 27 Feb 2024 12:18:27 +0100 Subject: [PATCH 27/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 2d5ab2d9c..12f8ffd8a 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -324,7 +324,7 @@ Read more in the [advisory: Content-Type Header ReDoS](https://github.com/tiango ### Upgrades -* ⬆️ Upgrade Starlette to `>=0.29.0,<0.33.0`, update docs and usage of templates with new Starlette arguments. PR [#10846](https://github.com/tiangolo/fastapi/pull/10846) by [@tiangolo](https://github.com/tiangolo). +* ⬆️ Upgrade Starlette to `>=0.29.0,<0.33.0`, update docs and usage of templates with new Starlette arguments. Remove pin of AnyIO `>=3.7.1,<4.0.0`, add support for AnyIO 4.x.x. PR [#10846](https://github.com/tiangolo/fastapi/pull/10846) by [@tiangolo](https://github.com/tiangolo). ## 0.107.0 From c0ad1ebabdb9e26b94c0e574c41bd6869e124bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 28 Feb 2024 15:04:08 +0100 Subject: [PATCH 28/29] =?UTF-8?q?=F0=9F=94=A7=20Update=20sponsors,=20remov?= =?UTF-8?q?e=20Jina,=20remove=20Powens,=20move=20TestDriven.io=20(#11213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 -- docs/en/data/sponsors.yml | 12 +++--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 874abf8c6..8d3e4c68d 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,7 @@ The key features are: - - diff --git a/docs/en/data/sponsors.yml b/docs/en/data/sponsors.yml index fd8518ce3..8401fd33e 100644 --- a/docs/en/data/sponsors.yml +++ b/docs/en/data/sponsors.yml @@ -27,15 +27,9 @@ silver: - url: https://training.talkpython.fm/fastapi-courses title: FastAPI video courses on demand from people you trust img: https://fastapi.tiangolo.com/img/sponsors/talkpython-v2.jpg - - url: https://testdriven.io/courses/tdd-fastapi/ - title: Learn to build high-quality web apps with best practices - img: https://fastapi.tiangolo.com/img/sponsors/testdriven.svg - url: https://github.com/deepset-ai/haystack/ title: Build powerful search from composable, open source building blocks img: https://fastapi.tiangolo.com/img/sponsors/haystack-fastapi.svg - - url: https://careers.powens.com/ - title: Powens is hiring! - img: https://fastapi.tiangolo.com/img/sponsors/powens.png - url: https://databento.com/ title: Pay as you go for market data img: https://fastapi.tiangolo.com/img/sponsors/databento.svg @@ -52,6 +46,6 @@ bronze: - url: https://www.exoflare.com/open-source/?utm_source=FastAPI&utm_campaign=open_source title: Biosecurity risk assessments made easy. img: https://fastapi.tiangolo.com/img/sponsors/exoflare.png - - url: https://bit.ly/3JJ7y5C - title: Build cross-modal and multimodal applications on the cloud - img: https://fastapi.tiangolo.com/img/sponsors/jina2.svg + - url: https://testdriven.io/courses/tdd-fastapi/ + title: Learn to build high-quality web apps with best practices + img: https://fastapi.tiangolo.com/img/sponsors/testdriven.svg From eef1b7d51530be64ddd48e02b5ca46f28a0ebfc1 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 28 Feb 2024 14:04:27 +0000 Subject: [PATCH 29/29] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index 12f8ffd8a..ad548327d 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -11,6 +11,10 @@ hide: * 🌐 Add Azerbaijani translation for `docs/az/learn/index.md`. PR [#11192](https://github.com/tiangolo/fastapi/pull/11192) by [@vusallyv](https://github.com/vusallyv). +### Internal + +* 🔧 Update sponsors, remove Jina, remove Powens, move TestDriven.io. PR [#11213](https://github.com/tiangolo/fastapi/pull/11213) by [@tiangolo](https://github.com/tiangolo). + ## 0.110.0 ### Breaking Changes