# UNDF: UNDF-2026-000000069 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -139,13 +139,13 @@ def _get_dependant_for_depends( def get_flat_dependant( dependant: Dependant, *, skip_repeats: bool = False, - visited: list[DependencyCacheKey] | None = None, + visited: set[DependencyCacheKey] | None = None, parent_oauth_scopes: list[str] | None = None, ) -> Dependant: if visited is None: - visited = [] - visited.append(dependant.cache_key) + visited = set() + visited.add(dependant.cache_key) use_parent_oauth_scopes = (parent_oauth_scopes or []) + ( dependant.oauth_scopes or [] )