Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/advanced/advanced-dependencies.md` (#12675)

pull/12794/head
kim-sangah 5 months ago
committed by GitHub
parent
commit
321053bdef
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 179
      docs/ko/docs/advanced/advanced-dependencies.md

179
docs/ko/docs/advanced/advanced-dependencies.md

@ -0,0 +1,179 @@
# ๊ณ ๊ธ‰ ์˜์กด์„ฑ
## ๋งค๊ฐœ๋ณ€์ˆ˜ํ™”๋œ ์˜์กด์„ฑ
์ง€๊ธˆ๊นŒ์ง€ ๋ณธ ๋ชจ๋“  ์˜์กด์„ฑ์€ ๊ณ ์ •๋œ ํ•จ์ˆ˜ ๋˜๋Š” ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ•จ์ˆ˜๋‚˜ ํด๋ž˜์Šค๋ฅผ ์„ ์–ธํ•˜์ง€ ์•Š๊ณ ๋„ ์˜์กด์„ฑ์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด, `q` ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ํŠน์ • ๊ณ ์ •๋œ ๋‚ด์šฉ์„ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ์˜์กด์„ฑ์„ ์›ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด ๋ด…์‹œ๋‹ค.
์ด๋•Œ ํ•ด๋‹น ๊ณ ์ •๋œ ๋‚ด์šฉ์„ ๋งค๊ฐœ๋ณ€์ˆ˜ํ™”ํ•  ์ˆ˜ ์žˆ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.
## "ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•œ" ์ธ์Šคํ„ด์Šค
Python์—๋Š” ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ "ํ˜ธ์ถœ ๊ฐ€๋Šฅ"ํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.
ํด๋ž˜์Šค ์ž์ฒด(์ด๋ฏธ ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•จ)๊ฐ€ ์•„๋‹ˆ๋ผ ํ•ด๋‹น ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค์— ๋Œ€ํ•ด ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
์ด๋ฅผ ์œ„ํ•ด `__call__` ๋ฉ”์„œ๋“œ๋ฅผ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค:
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
//// tab | Python 3.8+ non-Annotated
/// tip | ์ฐธ๊ณ 
๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด `Annotated` ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
///
```Python hl_lines="10"
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
์ด ๊ฒฝ์šฐ, **FastAPI**๋Š” ์ถ”๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ํ•˜์œ„ ์˜์กด์„ฑ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด `__call__`์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉฐ,
๋‚˜์ค‘์— *๊ฒฝ๋กœ ์—ฐ์‚ฐ ํ•จ์ˆ˜*์—์„œ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๊ฐ’์„ ์ „๋‹ฌํ•  ๋•Œ ์ด๋ฅผ ํ˜ธ์ถœํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
## ์ธ์Šคํ„ด์Šค ๋งค๊ฐœ๋ณ€์ˆ˜ํ™”ํ•˜๊ธฐ
์ด์ œ `__init__`์„ ์‚ฌ์šฉํ•˜์—ฌ ์˜์กด์„ฑ์„ "๋งค๊ฐœ๋ณ€์ˆ˜ํ™”"ํ•  ์ˆ˜ ์žˆ๋Š” ์ธ์Šคํ„ด์Šค์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
//// tab | Python 3.8+ non-Annotated
/// tip | ์ฐธ๊ณ 
๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด `Annotated` ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
///
```Python hl_lines="7"
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
์ด ๊ฒฝ์šฐ, **FastAPI**๋Š” `__init__`์— ์ „ํ˜€ ๊ด€์—ฌํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์šฐ๋ฆฌ๋Š” ์ด ๋ฉ”์„œ๋“œ๋ฅผ ์ฝ”๋“œ์—์„œ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
## ์ธ์Šคํ„ด์Šค ์ƒ์„ฑํ•˜๊ธฐ
๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ด ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
//// tab | Python 3.9+
```Python hl_lines="18"
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="17"
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
//// tab | Python 3.8+ non-Annotated
/// tip | ์ฐธ๊ณ 
๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด `Annotated` ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
///
```Python hl_lines="16"
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
์ด๋ ‡๊ฒŒ ํ•˜๋ฉด `checker.fixed_content` ์†์„ฑ์— `"bar"`๋ผ๋Š” ๊ฐ’์„ ๋‹ด์•„ ์˜์กด์„ฑ์„ "๋งค๊ฐœ๋ณ€์ˆ˜ํ™”"ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
## ์ธ์Šคํ„ด์Šค๋ฅผ ์˜์กด์„ฑ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ
๊ทธ๋Ÿฐ ๋‹ค์Œ, `Depends(FixedContentQueryChecker)` ๋Œ€์‹  `Depends(checker)`์—์„œ ์ด `checker` ์ธ์Šคํ„ด์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ,
ํด๋ž˜์Šค ์ž์ฒด๊ฐ€ ์•„๋‹Œ ์ธ์Šคํ„ด์Šค `checker`๊ฐ€ ์˜์กด์„ฑ์ด ๋ฉ๋‹ˆ๋‹ค.
์˜์กด์„ฑ์„ ํ•ด๊ฒฐํ•  ๋•Œ **FastAPI**๋Š” ์ด `checker`๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค:
```Python
checker(q="somequery")
```
...๊ทธ๋ฆฌ๊ณ  ์ด๋•Œ ๋ฐ˜ํ™˜๋˜๋Š” ๊ฐ’์„ *๊ฒฝ๋กœ ์—ฐ์‚ฐ ํ•จ์ˆ˜*์˜ `fixed_content_included` ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค:
//// tab | Python 3.9+
```Python hl_lines="22"
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="21"
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
//// tab | Python 3.8+ non-Annotated
/// tip | ์ฐธ๊ณ 
๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด `Annotated` ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
///
```Python hl_lines="20"
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
/// tip | ์ฐธ๊ณ 
์ด ๋ชจ๋“  ๊ณผ์ •์ด ๋ณต์žกํ•˜๊ฒŒ ๋Š๊ปด์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ง€๊ธˆ์€ ์ด ๋ฐฉ๋ฒ•์ด ์–ผ๋งˆ๋‚˜ ์œ ์šฉํ•œ์ง€ ๋ช…ํ™•ํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์˜ˆ์‹œ๋Š” ์˜๋„์ ์œผ๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์—ˆ์ง€๋งŒ, ์ „์ฒด ๊ตฌ์กฐ๊ฐ€ ์–ด๋–ป๊ฒŒ ์ž‘๋™ํ•˜๋Š”์ง€ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.
๋ณด์•ˆ ๊ด€๋ จ ์žฅ์—์„œ๋Š” ์ด์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„๋œ ํŽธ์˜ ํ•จ์ˆ˜๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ๋ชจ๋“  ๊ณผ์ •์„ ์ดํ•ดํ–ˆ๋‹ค๋ฉด, ์ด๋Ÿฌํ•œ ๋ณด์•ˆ ๋„๊ตฌ๋“ค์ด ๋‚ด๋ถ€์ ์œผ๋กœ ์–ด๋–ป๊ฒŒ ์ž‘๋™ํ•˜๋Š”์ง€ ์ด๋ฏธ ํŒŒ์•…ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
///
Loadingโ€ฆ
Cancel
Save