diff --git a/litestar/contrib/pydantic/pydantic_schema_plugin.py b/litestar/contrib/pydantic/pydantic_schema_plugin.py index fdb0ccfad2..bc0e5ef4a9 100644 --- a/litestar/contrib/pydantic/pydantic_schema_plugin.py +++ b/litestar/contrib/pydantic/pydantic_schema_plugin.py @@ -134,7 +134,7 @@ pydantic_v1.PositiveInt: Schema(type=OpenAPIType.INTEGER, exclusive_minimum=0), } -if pydantic_v2 is not None: +if pydantic_v2 is not None: # pragma: no cover PYDANTIC_TYPE_MAP.update( { pydantic_v2.ByteSize: Schema(type=OpenAPIType.INTEGER), @@ -190,7 +190,7 @@ _supported_types = (pydantic_v1.BaseModel, *PYDANTIC_TYPE_MAP.keys()) -if pydantic_v2 is not None: +if pydantic_v2 is not None: # pragma: no cover _supported_types = (pydantic_v2.BaseModel, *_supported_types) diff --git a/litestar/contrib/pydantic/utils.py b/litestar/contrib/pydantic/utils.py index d3905e3488..4bd48e4a00 100644 --- a/litestar/contrib/pydantic/utils.py +++ b/litestar/contrib/pydantic/utils.py @@ -47,10 +47,10 @@ def is_pydantic_model_class( Returns: A typeguard determining whether the type is :data:`BaseModel pydantic.BaseModel>`. """ - if pydantic_v1 is Empty: # type: ignore[comparison-overlap] + if pydantic_v1 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return False - if pydantic_v2 is Empty: # type: ignore[comparison-overlap] + if pydantic_v2 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return is_class_and_subclass(annotation, pydantic_v1.BaseModel) return is_class_and_subclass(annotation, (pydantic_v1.BaseModel, pydantic_v2.BaseModel)) @@ -67,10 +67,10 @@ def is_pydantic_model_instance( Returns: A typeguard determining whether the type is :data:`BaseModel pydantic.BaseModel>`. """ - if pydantic_v1 is Empty: # type: ignore[comparison-overlap] + if pydantic_v1 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return False - if pydantic_v2 is Empty: # type: ignore[comparison-overlap] + if pydantic_v2 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return isinstance(annotation, pydantic_v1.BaseModel) return isinstance(annotation, (pydantic_v1.BaseModel, pydantic_v2.BaseModel)) @@ -85,7 +85,7 @@ def is_pydantic_constrained_field(annotation: Any) -> Any: Returns: True if pydantic is installed and the type is a constrained type, otherwise False. """ - if pydantic_v1 is Empty: # type: ignore[comparison-overlap] + if pydantic_v1 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return False return any( @@ -107,10 +107,10 @@ def is_pydantic_constrained_field(annotation: Any) -> Any: def is_pydantic_field_info( obj: Any, ) -> TypeGuard[pydantic_v1.fields.FieldInfo | pydantic_v2.fields.FieldInfo]: # pyright: ignore - if pydantic_v1 is Empty: # type: ignore[comparison-overlap] + if pydantic_v1 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return False - if pydantic_v2 is Empty: # type: ignore[comparison-overlap] + if pydantic_v2 is Empty: # type: ignore[comparison-overlap] # pragma: no cover return isinstance(obj, pydantic_v1.fields.FieldInfo) return isinstance(obj, (pydantic_v1.fields.FieldInfo, pydantic_v2.fields.FieldInfo))