- Sort Score
- Result 10 results
- Languages All
Results 141 - 150 of 1,304 for def (0.01 sec)
-
tests/test_union_body_discriminator_annotated.py
] app = FastAPI() @app.post("/pet/assignment") async def create_pet_assignment(pet: Pet = Body()): return pet @app.post("/pet/annotated") async def create_pet_annotated(pet: Annotated[Pet, Body()]): return pet client = TestClient(app) return client def test_union_body_discriminator_assignment(client: TestClient) -> None:Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 20 15:55:38 UTC 2025 - 7.7K bytes - Viewed (0) -
docs/fr/docs/async.md
```Python hl_lines="2" @app.get('/') def results(): results = some_library() return results ``` --- Si votre application n'a pas à communiquer avec une bibliothèque externe et pas à attendre de réponse, utilisez `async def`. --- Si vous ne savez pas, utilisez seulement `def` comme vous le feriez habituellement. ---
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sun Aug 31 09:56:21 UTC 2025 - 25.4K bytes - Viewed (0) -
fastapi/security/http.py
) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error def make_authenticate_headers(self) -> dict[str, str]: return {"WWW-Authenticate": f"{self.model.scheme.title()}"} def make_not_authenticated_error(self) -> HTTPException: return HTTPException( status_code=HTTP_401_UNAUTHORIZED,Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 13.2K bytes - Viewed (0) -
tests/test_ws_dependencies.py
from typing import Annotated from fastapi import APIRouter, Depends, FastAPI, WebSocket from fastapi.testclient import TestClient def dependency_list() -> list[str]: return [] DepList = Annotated[list[str], Depends(dependency_list)] def create_dependency(name: str): def fun(deps: DepList): deps.append(name) return Depends(fun)
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 2.1K bytes - Viewed (0) -
fastapi/utils.py
_invalid_args_message.format(type_=type_) ) from None def create_cloned_field( field: ModelField, *, cloned_types: Optional[MutableMapping[type[BaseModel], type[BaseModel]]] = None, ) -> ModelField: return field def generate_operation_id_for_path( *, name: str, path: str, method: str ) -> str: # pragma: nocover warnings.warn(
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 5.1K bytes - Viewed (0) -
tests/test_invalid_sequence_param.py
from fastapi import FastAPI, Query from pydantic import BaseModel def test_invalid_sequence(): with pytest.raises(AssertionError): app = FastAPI() class Item(BaseModel): title: str @app.get("/items/") def read_items(q: list[Item] = Query(default=None)): pass # pragma: no cover def test_invalid_tuple(): with pytest.raises(AssertionError):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.2K bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial006.py
params=[ pytest.param("tutorial006_py39"), pytest.param("tutorial006_an_py39"), ], ) def get_client(request: pytest.FixtureRequest): mod = importlib.import_module(f"docs_src.dependencies.{request.param}") client = TestClient(mod.app) return client def test_get_no_headers(client: TestClient): response = client.get("/items/") assert response.status_code == 422, response.textRegistered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 4.8K bytes - Viewed (0) -
tests/test_tutorial/test_security/test_tutorial001.py
params=[ pytest.param("tutorial001_py39"), pytest.param("tutorial001_an_py39"), ], ) def get_client(request: pytest.FixtureRequest): mod = importlib.import_module(f"docs_src.security.{request.param}") client = TestClient(mod.app) return client def test_no_token(client: TestClient): response = client.get("/items") assert response.status_code == 401, response.textRegistered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 2.2K bytes - Viewed (0) -
tests/test_security_api_key_header_optional.py
api_key = APIKeyHeader(name="key", auto_error=False) class User(BaseModel): username: str def get_current_user(oauth_header: Optional[str] = Security(api_key)): if oauth_header is None: return None user = User(username=oauth_header) return user @app.get("/users/me") def read_current_user(current_user: Optional[User] = Depends(get_current_user)): if current_user is None:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2K bytes - Viewed (0) -
tests/test_security_http_digest_optional.py
security = HTTPDigest(auto_error=False) @app.get("/users/me") def read_current_user( credentials: Optional[HTTPAuthorizationCredentials] = Security(security), ): if credentials is None: return {"msg": "Create an account first"} return {"scheme": credentials.scheme, "credentials": credentials.credentials} client = TestClient(app) def test_security_http_digest():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Thu Feb 27 12:29:20 UTC 2025 - 2.2K bytes - Viewed (0)