codejump

Advanced Dependency Graphs

Preview — 3 of 10 questions

Two branches of a dependency graph share a sub-dependency that opens a resource. With default caching, how often is that sub-dependency normally entered in one request?

AOnce, with the result shared by the branches
BOnce for each branch regardless of caching
COnly once at application startup
DNever until the response is sent

A configured checker = Checker("admin") instance has __call__(q: str = ""). What does Depends(checker) inspect per request?

AThe class constructor, recreating checker on every request
BOnly the route handler's return annotation
CNo signature, because instances cannot be dependencies
DThe instance's __call__ signature, while "admin" remains its configured state

A class Filters is supplied as Depends(Filters), while shared = Filters(...) is supplied as Depends(shared) and implements __call__. What differs?

AThe instance cannot access request parameters
BThe class can only be called at startup
CThe class can be constructed during dependency resolution; the instance is already constructed
DBoth always construct a new Filters object

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.