(
dependant: Dependant,
*,
skip_repeats: bool = False,
visited: list[DependencyCacheKey] | None = None,
parent_oauth_scopes: list[str] | None = None,
)
| 136 | |
| 137 | |
| 138 | def get_flat_dependant( |
| 139 | dependant: Dependant, |
| 140 | *, |
| 141 | skip_repeats: bool = False, |
| 142 | visited: list[DependencyCacheKey] | None = None, |
| 143 | parent_oauth_scopes: list[str] | None = None, |
| 144 | ) -> Dependant: |
| 145 | if visited is None: |
| 146 | visited = [] |
| 147 | visited.append(dependant.cache_key) |
| 148 | use_parent_oauth_scopes = (parent_oauth_scopes or []) + ( |
| 149 | dependant.oauth_scopes or [] |
| 150 | ) |
| 151 | |
| 152 | flat_dependant = Dependant( |
| 153 | path_params=dependant.path_params.copy(), |
| 154 | query_params=dependant.query_params.copy(), |
| 155 | header_params=dependant.header_params.copy(), |
| 156 | cookie_params=dependant.cookie_params.copy(), |
| 157 | body_params=dependant.body_params.copy(), |
| 158 | name=dependant.name, |
| 159 | call=dependant.call, |
| 160 | request_param_name=dependant.request_param_name, |
| 161 | websocket_param_name=dependant.websocket_param_name, |
| 162 | http_connection_param_name=dependant.http_connection_param_name, |
| 163 | response_param_name=dependant.response_param_name, |
| 164 | background_tasks_param_name=dependant.background_tasks_param_name, |
| 165 | security_scopes_param_name=dependant.security_scopes_param_name, |
| 166 | own_oauth_scopes=dependant.own_oauth_scopes, |
| 167 | parent_oauth_scopes=use_parent_oauth_scopes, |
| 168 | use_cache=dependant.use_cache, |
| 169 | path=dependant.path, |
| 170 | scope=dependant.scope, |
| 171 | ) |
| 172 | for sub_dependant in dependant.dependencies: |
| 173 | if skip_repeats and sub_dependant.cache_key in visited: |
| 174 | continue |
| 175 | flat_sub = get_flat_dependant( |
| 176 | sub_dependant, |
| 177 | skip_repeats=skip_repeats, |
| 178 | visited=visited, |
| 179 | parent_oauth_scopes=flat_dependant.oauth_scopes, |
| 180 | ) |
| 181 | flat_dependant.dependencies.append(flat_sub) |
| 182 | flat_dependant.path_params.extend(flat_sub.path_params) |
| 183 | flat_dependant.query_params.extend(flat_sub.query_params) |
| 184 | flat_dependant.header_params.extend(flat_sub.header_params) |
| 185 | flat_dependant.cookie_params.extend(flat_sub.cookie_params) |
| 186 | flat_dependant.body_params.extend(flat_sub.body_params) |
| 187 | flat_dependant.dependencies.extend(flat_sub.dependencies) |
| 188 | |
| 189 | return flat_dependant |
| 190 | |
| 191 | |
| 192 | def _get_flat_fields_from_params(fields: list[ModelField]) -> list[ModelField]: |
no test coverage detected
searching dependent graphs…