Skip to main content

get_flat_dependant

Recursively flattens a Dependant object and its sub-dependencies into a single Dependant object, aggregating all parameters and dependencies. It can optionally skip repeated dependencies to avoid infinite recursion.

def get_flat_dependant(
dependant: Dependant,
skip_repeats: bool = False,
visited: list[DependencyCacheKey] | None = None,
parent_oauth_scopes: list[str] | None = None
) - > Dependant

Recursively flattens a Dependant object by consolidating all its sub-dependencies into a single Dependant object. This is useful for processing a dependency tree as a single unit, combining parameters and OAuth scopes from all levels.

Parameters

NameTypeDescription
dependantDependantThe initial Dependant object to flatten, which may contain nested dependencies.
skip_repeatsbool = FalseA boolean flag indicating whether to skip processing sub-dependencies that have already been visited during the flattening process, preventing infinite recursion in cyclic dependency graphs.
visited`list[DependencyCacheKey]None` = None
parent_oauth_scopes`list[str]None` = None

Returns

TypeDescription
DependantA new Dependant object representing the flattened structure, containing all parameters and OAuth scopes from the original dependant and its sub-dependencies.