Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/pydantype/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Union, get_origin, get_args
from pydantic import BaseModel

def is_pydantic_model(obj: Any) -> bool:
return isinstance(obj, type) and issubclass(obj, BaseModel)
def is_pydantic_model(type_: type) -> bool:
return isinstance(type_, type) and not isinstance(type_, GenericAlias) and (issubclass(type_, BaseModel))

def is_optional(annotation: Any) -> bool:
return get_origin(annotation) is Union and type(None) in get_args(annotation)
return get_origin(annotation) is Union and type(None) in get_args(annotation)