Browse Source

🎨 Auto format

pull/14751/head
pre-commit-ci-lite[bot] 6 months ago
committed by GitHub
parent
commit
ee496848c8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      docs/en/docs/tutorial/body.md
  2. 2
      docs_src/body/tutorial005_py310.py
  3. 3
      docs_src/body/tutorial005_py39.py
  4. 2
      tests/test_tutorial/test_body_required_nullable/test_tutorial001.py

2
docs/en/docs/tutorial/body.md

@ -55,7 +55,7 @@ For example, this model above declares a JSON "`object`" (or Python `dict`) like
}
```
### Required fields that can be `None`
### Required fields that can be `None` { #required-fields-that-can-be-none }
In Python type hints, a parameter can be **required** and still allow the value `None`.

2
docs_src/body/tutorial005_py310.py

@ -3,9 +3,11 @@ from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
description: str | None
@app.post("/items/")
async def create_item(item: Item):
return item

3
docs_src/body/tutorial005_py39.py

@ -1,12 +1,15 @@
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
description: Optional[str]
@app.post("/items/")
async def create_item(item: Item):
return item

2
tests/test_tutorial/test_body_required_nullable/test_tutorial001.py

@ -1,9 +1,11 @@
import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310
@pytest.fixture(
name="client",
params=[

Loading…
Cancel
Save