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 dependant.computed_scope == "request"
and param_details.depends.scope == "function" and param_details.depends.scope == "function"
): ):
assert dependant.call
raise DependencyScopeError( raise DependencyScopeError(
f'The dependency {dependant} has a scope of "request", it' f'The dependency "{dependant.call.__name__}" has a scope of '
'cannot depend on dependencies with scope "function".' '"request", it cannot depend on dependencies with scope "function".'
) )
use_security_scopes = security_scopes or [] use_security_scopes = security_scopes or []
if isinstance(param_details.depends, params.Security): if isinstance(param_details.depends, params.Security):

Loading…
Cancel
Save