Skip to content

Commit

Permalink
fix coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Janek Nouvertné <[email protected]>
  • Loading branch information
provinzkraut committed Oct 27, 2023
1 parent bbd6d38 commit 0dc19ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions litestar/contrib/pydantic/pydantic_schema_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)


Expand Down
14 changes: 7 additions & 7 deletions litestar/contrib/pydantic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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(
Expand All @@ -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))
Expand Down

0 comments on commit 0dc19ec

Please sign in to comment.