- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 186 for Depends (0.04 seconds)
-
tests/test_depends_hashable.py
# This is more or less a workaround to make Depends and Security hashable # as other tools that use them depend on that # Ref: https://github.com/fastapi/fastapi/pull/14320 from fastapi import Depends, Security def dep(): pass def test_depends_hashable(): dep() # just for coverage d1 = Depends(dep) d2 = Depends(dep) d3 = Depends(dep, scope="function") d4 = Depends(dep, scope="function")
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Nov 19 16:50:18 GMT 2025 - 596 bytes - Click Count (0) -
fastapi/dependencies/utils.py
if isinstance(field_info, FieldInfo): field_info.annotation = type_annotation # Get Depends from type annotation if depends is not None and depends.dependency is None: # Copy `depends` before mutating it depends = copy(depends) depends = dataclasses.replace(depends, dependency=type_annotation) # Handle non-param type annotations like Request if lenient_issubclass(
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Dec 27 12:54:56 GMT 2025 - 37.6K bytes - Click Count (3) -
tests/test_dependency_class.py
): return await instance(value) @app.get("/async-callable-gen-dependency-class") async def get_async_callable_gen_dependency_class( value: str, instance: AsyncCallableGenDependency = Depends() ): return await instance(value).__anext__() @app.get("/callable-dependency") async def get_callable_dependency(value: str = Depends(callable_dependency)): return valueCreated: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 4.4K bytes - Click Count (0) -
docs/pt/docs/tutorial/dependencies/index.md
Ainda que `Depends` seja utilizado nos parâmetros da função da mesma forma que `Body`, `Query`, etc, `Depends` funciona de uma forma um pouco diferente. Você fornece um único parâmetro para `Depends`. Esse parâmetro deve ser algo como uma função. Você **não chama a função** diretamente (não adicione os parênteses no final), apenas a passe como parâmetro de `Depends()`.
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Nov 12 16:23:57 GMT 2025 - 10.7K bytes - Click Count (0) -
tests/test_dependency_overrides.py
@app.get("/decorator-depends/", dependencies=[Depends(common_parameters)]) async def decorator_depends(): return {"in": "decorator-depends"} @router.get("/router-depends/") async def router_depends(commons: dict = Depends(common_parameters)): return {"in": "router-depends", "params": commons} @router.get("/router-decorator-depends/", dependencies=[Depends(common_parameters)]) async def router_decorator_depends():
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Dec 27 18:19:10 GMT 2025 - 11.2K bytes - Click Count (0) -
docs_src/security/tutorial003_an_py310.py
return user async def get_current_active_user( current_user: Annotated[User, Depends(get_current_user)], ): if current_user.disabled: raise HTTPException(status_code=400, detail="Inactive user") return current_user @app.post("/token") async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]): user_dict = fake_users_db.get(form_data.username) if not user_dict:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Mon Nov 24 19:03:06 GMT 2025 - 2.5K bytes - Click Count (0) -
docs/en/docs/tutorial/dependencies/classes-as-dependencies.md
``` //// //// tab | Python 3.9+ non-Annotated /// tip Prefer to use the `Annotated` version if possible. /// ```Python commons: CommonQueryParams = Depends() ``` //// You declare the dependency as the type of the parameter, and you use `Depends()` without any parameter, instead of having to write the full class *again* inside of `Depends(CommonQueryParams)`.
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 6.7K bytes - Click Count (0) -
docs/pt/docs/tutorial/dependencies/classes-as-dependencies.md
``` //// //// tab | Python 3.9+ non-Annotated /// tip | Dica Utilize a versão com `Annotated` se possível. /// ```Python commons: CommonQueryParams = Depends() ``` //// Você declara a dependência como o tipo do parâmetro, e utiliza `Depends()` sem nenhum parâmetro, em vez de ter que escrever a classe *novamente* dentro de `Depends(CommonQueryParams)`.
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 7.3K bytes - Click Count (0) -
tests/test_dependency_wrapped.py
@app.get("/wrapped-dependency/") async def get_wrapped_dependency(value: bool = Depends(wrapped_dependency)): return value @app.get("/wrapped-gen-dependency/") async def get_wrapped_gen_dependency(value: bool = Depends(wrapped_gen_dependency)): return value @app.get("/async-wrapped-dependency/") async def get_async_wrapped_dependency(value: bool = Depends(async_wrapped_dependency)): return value
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 11.2K bytes - Click Count (0) -
tests/test_dependency_yield_scope.py
yield raise HTTPException(status_code=503, detail="Exception after yield") SessionFuncDep = Annotated[Session, Depends(dep_session, scope="function")] SessionRequestDep = Annotated[Session, Depends(dep_session, scope="request")] SessionDefaultDep = Annotated[Session, Depends(dep_session)] class NamedSession: def __init__(self, name: str = "default") -> None: self.name = nameCreated: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 6.7K bytes - Click Count (0)