Browse Source

Use Optional

pull/10223/head
chbndrhnns 2 years ago
parent
commit
4eb2bc4180
  1. 10
      tests/test_pydantic_v1_models.py

10
tests/test_pydantic_v1_models.py

@ -1,3 +1,5 @@
from typing import Optional
import pytest
from fastapi import Body, FastAPI
from fastapi._compat import PYDANTIC_V2
@ -12,9 +14,9 @@ if PYDANTIC_V2:
class Item(v1.BaseModel):
name: str
description: str | None = None
description: Optional[str] = None
price: float
tax: float | None = None
tax: Optional[float] = None
tags: list = []
class Model(v1.BaseModel):
@ -25,9 +27,9 @@ else:
class Item(BaseModel):
name: str
description: str | None = None
description: Optional[str] = None
price: float
tax: float | None = None
tax: Optional[float] = None
tags: list = []
class Model(BaseModel):

Loading…
Cancel
Save