Search Options

Results per page
Sort
Preferred Languages
Advance

Results 231 - 240 of 498 for Annotated (0.31 sec)

  1. tests/test_dependency_after_yield_streaming.py

        with acquire_session() as s:
            yield s
    
    
    def broken_dep_session() -> Any:
        with acquire_session() as s:
            s.open = False
            yield s
    
    
    SessionDep = Annotated[Session, Depends(dep_session)]
    BrokenSessionDep = Annotated[Session, Depends(broken_dep_session)]
    
    app = FastAPI()
    
    
    @app.get("/data")
    def get_data(session: SessionDep) -> Any:
        data = list(session)
        return data
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  2. docs_src/dependencies/tutorial008d_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("We don't swallow the internal error here, we raise again 😎")
            raise
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 734 bytes
    - Viewed (0)
  3. docs/zh/docs/tutorial/testing.md

    ```
    
    ////
    
    //// tab | Python 3.10+ non-Annotated
    
    /// tip | 提瀺
    
    Prefer to use the `Annotated` version if possible.
    
    ///
    
    ```Python
    {!> ../../docs_src/app_testing/app_b_py310/main.py!}
    ```
    
    ////
    
    //// tab | Python 3.8+ non-Annotated
    
    /// tip | 提瀺
    
    Prefer to use the `Annotated` version if possible.
    
    ///
    
    ```Python
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 5.9K bytes
    - Viewed (0)
  4. docs_src/custom_request_and_route/tutorial001_an_py39.py

    import gzip
    from typing import Annotated, Callable
    
    from fastapi import Body, FastAPI, Request, Response
    from fastapi.routing import APIRoute
    
    
    class GzipRequest(Request):
        async def body(self) -> bytes:
            if not hasattr(self, "_body"):
                body = await super().body()
                if "gzip" in self.headers.getlist("Content-Encoding"):
                    body = gzip.decompress(body)
                self._body = body
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 10 08:55:32 UTC 2025
    - 988 bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial014_an_py310.py

    import time
    from typing import Annotated
    
    from fastapi import Depends, FastAPI, HTTPException
    from fastapi.responses import StreamingResponse
    from sqlmodel import Field, Session, SQLModel, create_engine
    
    engine = create_engine("postgresql+psycopg://postgres:postgres@localhost/db")
    
    
    class User(SQLModel, table=True):
        id: int | None = Field(default=None, primary_key=True)
        name: str
    
    
    app = FastAPI()
    
    
    def get_session():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Sep 29 03:29:38 UTC 2025
    - 957 bytes
    - Viewed (0)
  6. docs_src/schema_extra_example/tutorial005_an_py310.py

    from typing import Annotated
    
    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int,
        item: Annotated[
            Item,
            Body(
                openapi_examples={
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Aug 26 18:03:13 UTC 2023
    - 1.5K bytes
    - Viewed (0)
  7. tests/test_request_params/test_body/test_list.py

    from typing import Annotated, Union
    
    import pytest
    from dirty_equals import IsOneOf, IsPartialDict
    from fastapi import Body, FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    from .utils import get_body_model_name
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:31:34 UTC 2025
    - 11.9K bytes
    - Viewed (0)
  8. tests/test_request_params/test_body/test_optional_str.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import Body, FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    from .utils import get_body_model_name
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.post("/optional-str", operation_id="optional_str")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 11.6K bytes
    - Viewed (0)
  9. docs/ko/docs/tutorial/dependencies/index.md

    λ‹¨μˆœνžˆ `Depends`에 λ„˜κ²¨μ£ΌκΈ°λ§Œ ν•˜λ©΄ 되며, **FastAPI**λŠ” λ‚˜λ¨Έμ§€λ₯Ό μ–΄μ°Œν• μ§€ μ•Œκ³  μžˆμŠ΅λ‹ˆλ‹€.
    
    ///
    
    ## `Annotated`인 μ˜μ‘΄μ„± κ³΅μœ ν•˜κΈ°
    
    μœ„μ˜ μ˜ˆμ œμ—μ„œ λͺ‡λͺ‡ μž‘μ€ **μ½”λ“œ 쀑볡**이 μžˆλ‹€λŠ” 것을 λ³΄μ•˜μ„ κ²λ‹ˆλ‹€.
    
    `common_parameters()`μ˜μ‘΄μ„ μ‚¬μš©ν•΄μ•Ό ν•œλ‹€λ©΄, νƒ€μž… λͺ…μ‹œμ™€ `Depends()`와 ν•¨κ»˜ 전체 λ§€κ°œλ³€μˆ˜λ₯Ό 적어야 ν•©λ‹ˆλ‹€:
    
    ```Python
    commons: Annotated[dict, Depends(common_parameters)]
    ```
    
    ν•˜μ§€λ§Œ `Annotated`λ₯Ό μ‚¬μš©ν•˜κ³  μžˆκΈ°μ—, `Annotated` 값을 λ³€μˆ˜μ— μ €μž₯ν•˜κ³  μ—¬λŸ¬ μž₯μ†Œμ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 11.1K bytes
    - Viewed (0)
  10. tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py

    # Ref: https://github.com/fastapi/fastapi/issues/14454
    
    from typing import Annotated
    
    from fastapi import Depends, FastAPI, Security
    from fastapi.security import OAuth2AuthorizationCodeBearer
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    
    oauth2_scheme = OAuth2AuthorizationCodeBearer(
        authorizationUrl="api/oauth/authorize",
        tokenUrl="/api/oauth/token",
        scopes={"read": "Read access", "write": "Write access"},
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 2.6K bytes
    - Viewed (0)
Back to top