Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix pydantic@v2 deprecation warning in tests #2340

Merged
merged 4 commits into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/unit/test_openapi/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import annotated_types
import msgspec
import pydantic
import pytest
from pydantic import BaseModel, Field
from typing_extensions import Annotated
Expand Down Expand Up @@ -264,7 +265,12 @@ class Lookup(msgspec.Struct):

def test_create_schema_for_pydantic_field() -> None:
class Model(BaseModel):
value: str = Field(title="title", description="description", example="example", max_length=16)
if pydantic.VERSION.startswith("1"):
value: str = Field(title="title", description="description", example="example", max_length=16)
else:
value: str = Field( # type: ignore[no-redef]
title="title", description="description", max_length=16, json_schema_extra={"example": "example"}
)

schemas: Dict[str, Schema] = {}
field_definition = FieldDefinition.from_kwarg(name="Model", annotation=Model)
Expand Down