Home / Function/ get_flat_models_from_annotation() — fastapi Function Reference

get_flat_models_from_annotation() — fastapi Function Reference

Architecture documentation for the get_flat_models_from_annotation() function in v2.py from the fastapi codebase.

Function python FastAPI Responses calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa["get_flat_models_from_annotation()"]
  3e134d50_38c1_8523_f518_6686c1d9752b["v2.py"]
  bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa -->|defined in| 3e134d50_38c1_8523_f518_6686c1d9752b
  dc2b68f6_efc4_8d5c_5dca_76c377de10e0["get_flat_models_from_field()"]
  dc2b68f6_efc4_8d5c_5dca_76c377de10e0 -->|calls| bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa
  eda91ac5_1bd0_0d8b_6e77_6b82c2f46ce9["lenient_issubclass()"]
  bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa -->|calls| eda91ac5_1bd0_0d8b_6e77_6b82c2f46ce9
  f63bbc7e_ffcd_ab71_6957_68be35f4793a["get_flat_models_from_model()"]
  bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa -->|calls| f63bbc7e_ffcd_ab71_6957_68be35f4793a
  style bac6078f_b791_0fe8_6d7e_8ee00c1d4eaa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/_compat/v2.py lines 388–401

def get_flat_models_from_annotation(
    annotation: Any, known_models: TypeModelSet
) -> TypeModelSet:
    origin = get_origin(annotation)
    if origin is not None:
        for arg in get_args(annotation):
            if lenient_issubclass(arg, (BaseModel, Enum)):
                if arg not in known_models:
                    known_models.add(arg)  # type: ignore[arg-type]
                    if lenient_issubclass(arg, BaseModel):
                        get_flat_models_from_model(arg, known_models=known_models)
            else:
                get_flat_models_from_annotation(arg, known_models=known_models)
    return known_models

Domain

Subdomains

Frequently Asked Questions

What does get_flat_models_from_annotation() do?
get_flat_models_from_annotation() is a function in the fastapi codebase, defined in fastapi/_compat/v2.py.
Where is get_flat_models_from_annotation() defined?
get_flat_models_from_annotation() is defined in fastapi/_compat/v2.py at line 388.
What does get_flat_models_from_annotation() call?
get_flat_models_from_annotation() calls 2 function(s): get_flat_models_from_model, lenient_issubclass.
What calls get_flat_models_from_annotation()?
get_flat_models_from_annotation() is called by 1 function(s): get_flat_models_from_field.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free