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

Pydantiv2.4.0 compat #738

Merged
merged 13 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion faststream/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Simple and fast framework to create message brokers based microservices"""
__version__ = "0.1.1"
__version__ = "0.1.2"


INSTALL_YAML = """
Expand Down
7 changes: 4 additions & 3 deletions faststream/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def raise_fastapi_validation_error(errors: List[Any], body: AnyDict) -> Never:

if PYDANTIC_V2:
from pydantic import ConfigDict as ConfigDict
from pydantic._internal._annotated_handlers import (
from pydantic.annotated_handlers import (
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
from pydantic_core import CoreSchema as CoreSchema
from pydantic_core import to_jsonable_python
from pydantic_core.core_schema import (
general_plain_validator_function as general_plain_validator_function,
with_info_plain_validator_function as with_info_plain_validator_function,
)

SCHEMA_FIELD = "json_schema_extra"
Expand Down Expand Up @@ -168,7 +168,8 @@ def model_to_jsonable(
def model_copy(model: ModelVar, **kwargs: Any) -> ModelVar:
return model.copy(**kwargs)

def general_plain_validator_function( # type: ignore[misc]
# TODO: pydantic types misc
def with_info_plain_validator_function( # type: ignore[misc]
function: Callable[..., Any],
*,
ref: Optional[str] = None,
Expand Down
4 changes: 2 additions & 2 deletions faststream/asyncapi/schema/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
JsonSchemaValue,
Required,
TypedDict,
general_plain_validator_function,
with_info_plain_validator_function,
is_installed,
)
from faststream.log import logger
Expand Down Expand Up @@ -54,7 +54,7 @@ def __get_pydantic_core_schema__(
source: Type[Any],
handler: Callable[[Any], CoreSchema],
) -> JsonSchemaValue:
return general_plain_validator_function(cls._validate)
return with_info_plain_validator_function(cls._validate)


class ContactDict(TypedDict, total=False):
Expand Down
10 changes: 6 additions & 4 deletions faststream/asyncapi/schema/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from faststream._compat import PYDANTIC_V2
from faststream.asyncapi.schema.utils import (
ExternalDocs,
ExternalDocsDict,
Tag,
TagDict,
)


Expand Down Expand Up @@ -72,8 +70,12 @@ class Message(BaseModel):
# examples
# traits

tags: Optional[List[Union[Tag, TagDict, Dict[str, Any]]]] = None
externalDocs: Optional[Union[ExternalDocs, ExternalDocsDict, Dict[str, Any]]] = None
tags: Optional[
List[Union[Tag, Dict[str, Any]]]
] = None # TODO: weird TagDict behavior
externalDocs: Optional[
Union[ExternalDocs, Dict[str, Any]]
] = None # TODO: weird ExternalDocsDict behavior

if PYDANTIC_V2:
model_config = {"extra": "allow"}
Expand Down