Skip to content

Commit

Permalink
Fixed redundant catching of AttributeError
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasrichter committed Nov 30, 2021
1 parent 2b5d561 commit edc0dc1
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions fastapi_injector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ def Injected(interface: BoundInterface) -> Any: # pylint: disable=invalid-name
"""

def inject_into_route(request: Request) -> BoundInterface:
try:
return get_injector_instance(request.app).get(interface)
except AttributeError as exc:
raise InjectorNotAttached(
"No injector instance has been attached to the app."
) from exc
return get_injector_instance(request.app).get(interface)

return Depends(inject_into_route)

Expand Down

0 comments on commit edc0dc1

Please sign in to comment.