MCPcopy
hub / github.com/fastapi/fastapi / get_flat_models_from_annotation

Function get_flat_models_from_annotation

fastapi/_compat/v2.py:446–459  ·  view source on GitHub ↗
(
    annotation: Any, known_models: TypeModelSet
)

Source from the content-addressed store, hash-verified

444
445
446def get_flat_models_from_annotation(
447 annotation: Any, known_models: TypeModelSet
448) -> TypeModelSet:
449 origin = get_origin(annotation)
450 if origin is not None:
451 for arg in get_args(annotation):
452 if lenient_issubclass(arg, (BaseModel, Enum)):
453 if arg not in known_models:
454 known_models.add(arg) # type: ignore[arg-type]
455 if lenient_issubclass(arg, BaseModel):
456 get_flat_models_from_model(arg, known_models=known_models)
457 else:
458 get_flat_models_from_annotation(arg, known_models=known_models)
459 return known_models
460
461
462def get_flat_models_from_field(

Callers 1

Calls 2

lenient_issubclassFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…