new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

FastAPI · Advanced · all subjects

advanced-dependencies/parameterized

2 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Create callable class instances for parameterized dependencies

In Python, you can make an instance of a class callable by declaring a `__call__` method. FastAPI will inspect this method to check for additional parameters and sub-dependencies, and will call it to pass a value to a path operation function parameter. The `__init__` method is used to parameterize the dependency instance without FastAPI touching it.

Using callable instances with Depends()

Pass a callable class instance directly to `Depends(instance)` rather than the class itself `Depends(Class)`. FastAPI will call the instance like `instance(param=value)` and pass whatever it returns as the dependency value to the path operation function.

Give your agent this brain