mirror of https://github.com/tiangolo/fastapi.git
Remove code examples for Python 3.8 in `header_param_models`
This commit is contained in:
parent
fa9d36d2f3
commit
e3ae463424
|
|
@ -1,19 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: CommonHeaders = Header()):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: Annotated[CommonHeaders, Header()]):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
model_config = {"extra": "forbid"}
|
|
||||||
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: CommonHeaders = Header()):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
model_config = {"extra": "forbid"}
|
|
||||||
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: Annotated[CommonHeaders, Header()]):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
class Config:
|
|
||||||
extra = "forbid"
|
|
||||||
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: CommonHeaders = Header()):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
class Config:
|
|
||||||
extra = "forbid"
|
|
||||||
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: Annotated[CommonHeaders, Header()]):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(headers: CommonHeaders = Header(convert_underscores=False)):
|
|
||||||
return headers
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
from typing import List, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class CommonHeaders(BaseModel):
|
|
||||||
host: str
|
|
||||||
save_data: bool
|
|
||||||
if_modified_since: Union[str, None] = None
|
|
||||||
traceparent: Union[str, None] = None
|
|
||||||
x_tag: List[str] = []
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/")
|
|
||||||
async def read_items(
|
|
||||||
headers: Annotated[CommonHeaders, Header(convert_underscores=False)],
|
|
||||||
):
|
|
||||||
return headers
|
|
||||||
|
|
@ -5,17 +5,15 @@ from dirty_equals import IsDict
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from inline_snapshot import snapshot
|
from inline_snapshot import snapshot
|
||||||
|
|
||||||
from tests.utils import needs_py39, needs_py310
|
from tests.utils import needs_py310
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
name="client",
|
name="client",
|
||||||
params=[
|
params=[
|
||||||
"tutorial001",
|
pytest.param("tutorial001_py39"),
|
||||||
pytest.param("tutorial001_py39", marks=needs_py39),
|
|
||||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||||
"tutorial001_an",
|
pytest.param("tutorial001_an_py39"),
|
||||||
pytest.param("tutorial001_an_py39", marks=needs_py39),
|
|
||||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,19 @@ from dirty_equals import IsDict
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from inline_snapshot import snapshot
|
from inline_snapshot import snapshot
|
||||||
|
|
||||||
from tests.utils import needs_py39, needs_py310, needs_pydanticv1, needs_pydanticv2
|
from tests.utils import needs_py310, needs_pydanticv1, needs_pydanticv2
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
name="client",
|
name="client",
|
||||||
params=[
|
params=[
|
||||||
pytest.param("tutorial002", marks=needs_pydanticv2),
|
pytest.param("tutorial002_py39", marks=needs_pydanticv2),
|
||||||
pytest.param("tutorial002_py310", marks=[needs_py310, needs_pydanticv2]),
|
pytest.param("tutorial002_py310", marks=[needs_py310, needs_pydanticv2]),
|
||||||
pytest.param("tutorial002_an", marks=needs_pydanticv2),
|
pytest.param("tutorial002_an_py39", marks=needs_pydanticv2),
|
||||||
pytest.param("tutorial002_an_py39", marks=[needs_py39, needs_pydanticv2]),
|
|
||||||
pytest.param("tutorial002_an_py310", marks=[needs_py310, needs_pydanticv2]),
|
pytest.param("tutorial002_an_py310", marks=[needs_py310, needs_pydanticv2]),
|
||||||
pytest.param("tutorial002_pv1", marks=[needs_pydanticv1, needs_pydanticv1]),
|
pytest.param("tutorial002_pv1_py39", marks=needs_pydanticv1),
|
||||||
pytest.param("tutorial002_pv1_py310", marks=[needs_py310, needs_pydanticv1]),
|
pytest.param("tutorial002_pv1_py310", marks=[needs_py310, needs_pydanticv1]),
|
||||||
pytest.param("tutorial002_pv1_an", marks=[needs_pydanticv1]),
|
pytest.param("tutorial002_pv1_an_py39", marks=needs_pydanticv1),
|
||||||
pytest.param("tutorial002_pv1_an_py39", marks=[needs_py39, needs_pydanticv1]),
|
|
||||||
pytest.param("tutorial002_pv1_an_py310", marks=[needs_py310, needs_pydanticv1]),
|
pytest.param("tutorial002_pv1_an_py310", marks=[needs_py310, needs_pydanticv1]),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,15 @@ from dirty_equals import IsDict
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from inline_snapshot import snapshot
|
from inline_snapshot import snapshot
|
||||||
|
|
||||||
from tests.utils import needs_py39, needs_py310
|
from tests.utils import needs_py310
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
name="client",
|
name="client",
|
||||||
params=[
|
params=[
|
||||||
"tutorial003",
|
pytest.param("tutorial003_py39"),
|
||||||
pytest.param("tutorial003_py39", marks=needs_py39),
|
|
||||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||||
"tutorial003_an",
|
pytest.param("tutorial003_an_py39"),
|
||||||
pytest.param("tutorial003_an_py39", marks=needs_py39),
|
|
||||||
pytest.param("tutorial003_an_py310", marks=needs_py310),
|
pytest.param("tutorial003_an_py310", marks=needs_py310),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue