MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / is_basemodel

Function is_basemodel

src/opencode_ai/_models.py:394–403  ·  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

392
393
394def is_basemodel(type_: type) -> bool:
395 """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
396 if is_union(type_):
397 for variant in get_args(type_):
398 if is_basemodel(variant):
399 return True
400
401 return False
402
403 return is_basemodel_type(type_)
404
405
406def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericModel]]:

Callers 1

_parseMethod · 0.85

Calls 3

is_unionFunction · 0.85
get_argsFunction · 0.85
is_basemodel_typeFunction · 0.85

Tested by

no test coverage detected