MCPcopy
hub / github.com/fastapi/fastapi / lenient_issubclass

Function lenient_issubclass

fastapi/_compat/shared.py:47–55  ·  view source on GitHub ↗
(
    cls: Any, class_or_tuple: type[_T] | tuple[type[_T], ...] | None
)

Source from the content-addressed store, hash-verified

45
46# Copy of Pydantic: pydantic/_internal/_utils.py with added TypeGuard
47def lenient_issubclass(
48 cls: Any, class_or_tuple: type[_T] | tuple[type[_T], ...] | None
49) -> TypeGuard[type[_T]]:
50 try:
51 return isinstance(cls, type) and issubclass(cls, class_or_tuple) # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
52 except TypeError: # pragma: no cover
53 if isinstance(cls, WithArgsTypes):
54 return False
55 raise # pragma: no cover
56
57
58def _annotation_is_sequence(annotation: type[Any] | None) -> bool:

Callers 15

get_request_handlerFunction · 0.90
get_openapi_pathFunction · 0.90
get_model_fieldsFunction · 0.90
analyze_paramFunction · 0.90
request_params_to_argsFunction · 0.90
is_union_of_base_modelsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…