Search Options

Results per page
Sort
Preferred Languages
Advance

Results 71 - 80 of 1,048 for strs (0.02 sec)

  1. tests/test_request_params/test_header/test_list.py

    # Without aliases
    
    
    @app.get("/required-list-str")
    async def read_required_list_str(p: Annotated[list[str], Header()]):
        return {"p": p}
    
    
    class HeaderModelRequiredListStr(BaseModel):
        p: list[str]
    
    
    @app.get("/model-required-list-str")
    def read_model_required_list_str(p: Annotated[HeaderModelRequiredListStr, Header()]):
        return {"p": p.p}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:31:34 UTC 2025
    - 11K bytes
    - Viewed (0)
  2. docs_src/response_model/tutorial003_01_py39.py

    from typing import Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel, EmailStr
    
    app = FastAPI()
    
    
    class BaseUser(BaseModel):
        username: str
        email: EmailStr
        full_name: Union[str, None] = None
    
    
    class UserIn(BaseUser):
        password: str
    
    
    @app.post("/user/")
    async def create_user(user: UserIn) -> BaseUser:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 349 bytes
    - Viewed (0)
  3. docs_src/cookie_param_models/tutorial002_an_py310.py

    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        model_config = {"extra": "forbid"}
    
        session_id: str
        fatebook_tracker: str | None = None
        googall_tracker: str | None = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 383 bytes
    - Viewed (0)
  4. docs_src/cookie_param_models/tutorial002_an_py39.py

    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        model_config = {"extra": "forbid"}
    
        session_id: str
        fatebook_tracker: Union[str, None] = None
        googall_tracker: Union[str, None] = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 402 bytes
    - Viewed (0)
  5. scripts/contributors.py

    class ContributorsResults(BaseModel):
        contributors: Counter[str]
        translation_reviewers: Counter[str]
        translators: Counter[str]
        authors: dict[str, Author]
    
    
    def get_contributors(pr_nodes: list[PullRequestNode]) -> ContributorsResults:
        contributors = Counter[str]()
        translation_reviewers = Counter[str]()
        translators = Counter[str]()
        authors: dict[str, Author] = {}
    
        for pr in pr_nodes:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Dec 16 12:34:01 UTC 2025
    - 8.6K bytes
    - Viewed (0)
  6. docs/en/docs/python-types.md

    ```Python hl_lines="1  4"
    {!../../docs_src/python_types/tutorial009_py39.py!}
    ```
    
    Using `Optional[str]` instead of just `str` will let the editor help you detect errors where you could be assuming that a value is always a `str`, when it could actually be `None` too.
    
    `Optional[Something]` is actually a shortcut for `Union[Something, None]`, they are equivalent.
    
    This also means that in Python 3.10, you can use `Something | None`:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 15.6K bytes
    - Viewed (0)
  7. tests/test_request_params/test_body/test_optional_list.py

        "path",
        ["/optional-list-str", "/model-optional-list-str"],
    )
    def test_optional_list_str_missing_empty_dict(path: str):
        client = TestClient(app)
        response = client.post(path, json={})
        assert response.status_code == 200, response.text
        assert response.json() == {"p": None}
    
    
    @pytest.mark.parametrize(
        "path",
        ["/optional-list-str", "/model-optional-list-str"],
    )
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 12.7K bytes
    - Viewed (0)
  8. docs_src/response_model/tutorial001_01_py310.py

    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
        tags: list[str] = []
    
    
    @app.post("/items/")
    async def create_item(item: Item) -> Item:
        return item
    
    
    @app.get("/items/")
    async def read_items() -> list[Item]:
        return [
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Jan 07 13:45:48 UTC 2023
    - 469 bytes
    - Viewed (0)
  9. tests/test_request_params/test_path/test_required_str.py

    app = FastAPI()
    
    
    @app.get("/required-str/{p}")
    async def read_required_str(p: Annotated[str, Path()]):
        return {"p": p}
    
    
    @app.get("/required-alias/{p_alias}")
    async def read_required_alias(p: Annotated[str, Path(alias="p_alias")]):
        return {"p": p}
    
    
    @app.get("/required-validation-alias/{p_val_alias}")
    def read_required_validation_alias(
        p: Annotated[str, Path(validation_alias="p_val_alias")],
    ):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 2.3K bytes
    - Viewed (0)
  10. tests/test_validate_response_recursive/app.py

    app = FastAPI()
    
    
    class RecursiveItem(BaseModel):
        sub_items: list["RecursiveItem"] = []
        name: str
    
    
    class RecursiveSubitemInSubmodel(BaseModel):
        sub_items2: list["RecursiveItemViaSubmodel"] = []
        name: str
    
    
    class RecursiveItemViaSubmodel(BaseModel):
        sub_items1: list[RecursiveSubitemInSubmodel] = []
        name: str
    
    
    RecursiveItem.model_rebuild()
    RecursiveSubitemInSubmodel.model_rebuild()
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1.1K bytes
    - Viewed (0)
Back to top