MCPcopy
hub / github.com/openai/openai-python / is_basemodel

Function is_basemodel

src/openai/_models.py:537–546  ·  view source on GitHub ↗

Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`

(type_: type)

Source from the content-addressed store, hash-verified

535
536
537def is_basemodel(type_: type) -> bool:
538 """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
539 if is_union(type_):
540 for variant in get_args(type_):
541 if is_basemodel(variant):
542 return True
543
544 return False
545
546 return is_basemodel_type(type_)
547
548
549def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericModel]]:

Callers 2

_parseMethod · 0.85
_parseMethod · 0.85

Calls 3

is_unionFunction · 0.70
get_argsFunction · 0.70
is_basemodel_typeFunction · 0.70

Tested by

no test coverage detected