Remove code examples for Python 3.8 in `body_fields`

This commit is contained in:
Yurii Motov 2025-12-10 15:46:28 +01:00
parent 9fb05d4cee
commit 332b405af0
3 changed files with 3 additions and 26 deletions

View File

@ -1,22 +0,0 @@
from typing import Union
from fastapi import Body, FastAPI
from pydantic import BaseModel, Field
from typing_extensions import Annotated
app = FastAPI()
class Item(BaseModel):
name: str
description: Union[str, None] = Field(
default=None, title="The description of the item", max_length=300
)
price: float = Field(gt=0, description="The price must be greater than zero")
tax: Union[float, None] = None
@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]):
results = {"item_id": item_id, "item": item}
return results

View File

@ -4,16 +4,15 @@ import pytest
from dirty_equals import IsDict
from fastapi.testclient import TestClient
from ...utils import needs_py39, needs_py310
from ...utils import needs_py310
@pytest.fixture(
name="client",
params=[
"tutorial001",
"tutorial001_py39",
pytest.param("tutorial001_py310", marks=needs_py310),
"tutorial001_an",
pytest.param("tutorial001_an_py39", marks=needs_py39),
"tutorial001_an_py39",
pytest.param("tutorial001_an_py310", marks=needs_py310),
],
)