Browse Source

♻️ Improve the error for broken scopes in dependencies

pull/14262/head
Sebastián Ramírez 9 months ago
parent
commit
936c1f415e
  1. 5
      fastapi/dependencies/utils.py

5
fastapi/dependencies/utils.py

@ -266,9 +266,10 @@ def get_dependant(
and dependant.computed_scope == "request"
and param_details.depends.scope == "function"
):
assert dependant.call
raise DependencyScopeError(
f'The dependency {dependant} has a scope of "request", it'
'cannot depend on dependencies with scope "function".'
f'The dependency "{dependant.call.__name__}" has a scope of '
'"request", it cannot depend on dependencies with scope "function".'
)
use_security_scopes = security_scopes or []
if isinstance(param_details.depends, params.Security):

Loading…
Cancel
Save