Sobes.tech
Back to tasks
Junior — Senior
65

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

Companies where asked:
Рексофт

Task condition

livecode

Разобрать пример на 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()
)