Browse Source

🎨 Auto format

pull/15178/head
github-actions[bot] 4 months ago
committed by Yurii Motov
parent
commit
b05643a722
  1. 8
      docs/zh-hant/docs/async.md
  2. 2
      docs/zh-hant/docs/fastapi-cli.md
  3. 10
      docs/zh-hant/docs/tutorial/index.md
  4. 4
      docs/zh-hant/docs/tutorial/query-params-str-validations.md
  5. 4
      docs/zh-hant/docs/virtual-environments.md

8
docs/zh-hant/docs/async.md

@ -298,7 +298,7 @@ def results():
這一點,再加上 Python 是 **資料科學**、機器學習,尤其是深度學習的主要語言,讓 **FastAPI** 成為資料科學/機器學習 Web API 和應用程式(以及許多其他應用程式)的絕佳選擇。 這一點,再加上 Python 是 **資料科學**、機器學習,尤其是深度學習的主要語言,讓 **FastAPI** 成為資料科學/機器學習 Web API 和應用程式(以及許多其他應用程式)的絕佳選擇。
想了解如何在生產環境中實現這種平行性,請參見 [部屬](deployment/index.md){.internal-link target=_blank} 想了解如何在生產環境中實現這種平行性,請參見 [部屬](deployment/index.md)。
## `async``await` { #async-and-await } ## `async``await` { #async-and-await }
@ -419,15 +419,15 @@ Starlette(和 **FastAPI**)是基於 [AnyIO](https://anyio.readthedocs.io/en/
如果你來自於其他不以這種方式運作的非同步框架,而且你習慣於使用普通的 `def` 定義僅進行簡單計算的*路徑操作函式*,目的是獲得微小的性能增益(大約 100 奈秒),請注意,在 FastAPI 中,效果會完全相反。在這些情況下,最好使用 `async def`,除非你的*路徑操作函式*執行阻塞的 <abbr title="Input/Output - 輸入/輸出: 磁碟讀寫或網路通訊。">I/O</abbr> 的程式碼。 如果你來自於其他不以這種方式運作的非同步框架,而且你習慣於使用普通的 `def` 定義僅進行簡單計算的*路徑操作函式*,目的是獲得微小的性能增益(大約 100 奈秒),請注意,在 FastAPI 中,效果會完全相反。在這些情況下,最好使用 `async def`,除非你的*路徑操作函式*執行阻塞的 <abbr title="Input/Output - 輸入/輸出: 磁碟讀寫或網路通訊。">I/O</abbr> 的程式碼。
不過,在這兩種情況下,**FastAPI** [仍然很快](index.md#performance){.internal-link target=_blank},至少與你之前的框架相當(或者更快)。 不過,在這兩種情況下,**FastAPI** [仍然很快](index.md#performance),至少與你之前的框架相當(或者更快)。
### 依賴項(Dependencies) { #dependencies } ### 依賴項(Dependencies) { #dependencies }
同樣適用於[依賴項](tutorial/dependencies/index.md){.internal-link target=_blank}。如果依賴項是一個標準的 `def` 函式,而不是 `async def`,那麼它在外部的執行緒池被運行。 同樣適用於[依賴項](tutorial/dependencies/index.md)。如果依賴項是一個標準的 `def` 函式,而不是 `async def`,那麼它在外部的執行緒池被運行。
### 子依賴項 { #sub-dependencies } ### 子依賴項 { #sub-dependencies }
你可以擁有多個相互依賴的依賴項和[子依賴項](tutorial/dependencies/sub-dependencies.md){.internal-link target=_blank}(作為函式定義的參數),其中一些可能是用 `async def` 宣告,也可能是用 `def` 宣告。它們仍然可以正常運作,用 `def` 定義的那些將會在外部的執行緒中呼叫(來自執行緒池),而不是被「等待」。 你可以擁有多個相互依賴的依賴項和[子依賴項](tutorial/dependencies/sub-dependencies.md)(作為函式定義的參數),其中一些可能是用 `async def` 宣告,也可能是用 `def` 宣告。它們仍然可以正常運作,用 `def` 定義的那些將會在外部的執行緒中呼叫(來自執行緒池),而不是被「等待」。
### 其他輔助函式 { #other-utility-functions } ### 其他輔助函式 { #other-utility-functions }

2
docs/zh-hant/docs/fastapi-cli.md

@ -58,7 +58,7 @@ $ <font color="#4E9A06">fastapi</font> dev
不過你也可以明確設定要使用的 app。 不過你也可以明確設定要使用的 app。
## 在 `pyproject.toml` 中設定應用程式的 `entrypoint` { #configure-the-app-entrypoint-in-pyproject.toml } ## 在 `pyproject.toml` 中設定應用程式的 `entrypoint` { #configure-the-app-entrypoint-in-pyproject-toml }
你可以在 `pyproject.toml` 檔案中指定你的 app 位置,例如: 你可以在 `pyproject.toml` 檔案中指定你的 app 位置,例如:

10
docs/zh-hant/docs/tutorial/index.md

@ -42,12 +42,12 @@ $ <font color="#4E9A06">fastapi</font> dev
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Will watch for changes in these directories: <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Will watch for changes in these directories:
<b>[</b><font color="#4E9A06">&apos;/home/user/code/awesomeapp&apos;</font><b>]</b> <b>[</b><font color="#4E9A06">&apos;/home/user/code/awesomeapp&apos;</font><b>]</b>
<span style="background-color="#007166"><font color="#D3D7CF"> INFO </font></span> Uvicorn running on <font color="#729FCF"><u style="text-decoration-style:solid">http://127.0.0.1:8000</u></font> <b>(</b>Press CTRL+C <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Uvicorn running on <font color="#729FCF"><u style="text-decoration-style:solid">http://127.0.0.1:8000</u></font> <b>(</b>Press CTRL+C
to quit<b>)</b> to quit<b>)</b>
<span style="background-color="#007166"><font color="#D3D7CF"> INFO </font></span> Started reloader process <b>[</b><font color="#34E2E2"><b>383138</b></font><b>]</b> using WatchFiles <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started reloader process <b>[</b><font color="#34E2E2"><b>383138</b></font><b>]</b> using WatchFiles
<span style="background-color="#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>383153</b></font><b>]</b> <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>383153</b></font><b>]</b>
<span style="background-color="#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup. <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
<span style="background-color="#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete. <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
``` ```
</div> </div>

4
docs/zh-hant/docs/tutorial/query-params-str-validations.md

@ -35,13 +35,13 @@ FastAPI 自 0.95.0 版起加入並開始推薦使用 `Annotated`。
如果你的版本較舊,嘗試使用 `Annotated` 會出錯。 如果你的版本較舊,嘗試使用 `Annotated` 會出錯。
請先至少 [升級 FastAPI 版本](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} 到 0.95.1 再使用 `Annotated` 請先至少 [升級 FastAPI 版本](../deployment/versions.md#upgrading-the-fastapi-versions) 到 0.95.1 再使用 `Annotated`
/// ///
## 在 `q` 參數的型別中使用 `Annotated` { #use-annotated-in-the-type-for-the-q-parameter } ## 在 `q` 參數的型別中使用 `Annotated` { #use-annotated-in-the-type-for-the-q-parameter }
還記得先前在 [Python 型別介紹](../python-types.md#type-hints-with-metadata-annotations){.internal-link target=_blank} 提到可以用 `Annotated` 為參數加入中繼資料嗎? 還記得先前在 [Python 型別介紹](../python-types.md#type-hints-with-metadata-annotations) 提到可以用 `Annotated` 為參數加入中繼資料嗎?
現在就用在 FastAPI 上吧。🚀 現在就用在 FastAPI 上吧。🚀

4
docs/zh-hant/docs/virtual-environments.md

@ -639,13 +639,13 @@ $ source .venv/Scripts/activate
//// ////
這個命令會建立或修改一些[環境變數](environment-variables.md){.internal-link target=_blank},這些環境變數將在接下來的指令中可用。 這個命令會建立或修改一些[環境變數](environment-variables.md),這些環境變數將在接下來的指令中可用。
其中之一是 `PATH` 變數。 其中之一是 `PATH` 變數。
/// tip /// tip
你可以在 [環境變數](environment-variables.md#path-environment-variable){.internal-link target=_blank} 部分了解更多關於 `PATH` 環境變數的內容。 你可以在 [環境變數](environment-variables.md#path-environment-variable) 部分了解更多關於 `PATH` 環境變數的內容。
/// ///

Loading…
Cancel
Save