Skip to content

Commit

Permalink
Fix assertion for new Pydantic 2 behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato committed Nov 3, 2023
1 parent a91205b commit 26b75b1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions tests/test_openapi_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ValueFormat,
ValueType,
)
from pydantic import VERSION, BaseModel, HttpUrl
from pydantic import VERSION as PYDANTIC_LIB_VERSION, BaseModel, HttpUrl
from pydantic.types import NegativeFloat, PositiveInt, condecimal, confloat, conint

from blacksheep.server.application import Application
Expand All @@ -44,20 +44,13 @@
from blacksheep.server.routing import RoutesRegistry

GenericModel = BaseModel

PYDANTIC_VERSION = 2
if int(VERSION[0]) < 2:

if int(PYDANTIC_LIB_VERSION[0]) < 2:
from pydantic.generics import GenericModel

PYDANTIC_VERSION = 1
# try:
# from pydantic.generics import GenericModel
# except ImportError:
# # Pydantic v2
# # https://docs.pydantic.dev/latest/blog/pydantic-v2/#other-improvements
# GenericModel = BaseModel
# PYDANTIC_VERSION = 2
# else:
# PYDANTIC_VERSION = 1

try:
from pydantic import field_validator
Expand Down Expand Up @@ -212,7 +205,7 @@ class PydConstrained(BaseModel):
b: NegativeFloat
big_int: conint(gt=1000, lt=1024)

big_float: confloat(gt=1000, lt=1024)
big_float: confloat(gt=1000.0, lt=1024.0)
unit_interval: confloat(ge=0, le=1)

decimal_positive: condecimal(gt=0)
Expand Down

0 comments on commit 26b75b1

Please sign in to comment.