Sobes.tech
Back to tasks
Junior — Senior
22

Сравнение применения Depends и обычного вызова функции в FastAPI

Companies where asked:

Рексофт
Get help with live coding in real time with Sobes Copilot
Task condition

Разобрать пример на FastAPI и понять, какие выгоды даёт использование Depends(get_current_user) по сравнению с прямым вызовом get_current_user().

# FastAPI
Depends()
@router.get('/books')
async def list_books(
    user=Depends(get_current_user),
    user=get_current_user()
)