That also applies to callables with no parameters at all. The same as it would be for *path operation functions* with no parameters.
-Then, we can change the dependency "dependable" `common_parameters` from above to the class `CommonQueryParameters`:
+Then, we can change the dependency "dependable" `common_parameters` from above to the class `CommonQueryParams`:
```Python hl_lines="11 12 13 14 15"
{!../../../docs_src/dependencies/tutorial002.py!}
Now you can declare your dependency using this class.
-And as when **FastAPI** calls that class the value that will be passed as `commons` to your function will be an "instance" of the class, you can declare that parameter `commons` to be of type of the class, `CommonQueryParams`.
-
```Python hl_lines="19"
{!../../../docs_src/dependencies/tutorial002.py!}
```
+**FastAPI** calls the `CommonQueryParams` class. This creates an "instance" of that class and the instance will be passed as the parameter `commons` to your function.
+
## Type annotation vs `Depends`
-In the code above, you are declaring `commons` as:
+Notice how we write `CommonQueryParams` twice in the above code:
```Python
commons: CommonQueryParams = Depends(CommonQueryParams)
commons: CommonQueryParams = Depends()
```
-So, you can declare the dependency as the type of the variable, and use `Depends()` as the "default" value (the value after the `=`) for that function's parameter, without any parameter, instead of having to write the full class *again* inside of `Depends(CommonQueryParams)`.
+You declare the dependency as the type of the parameter, and you use `Depends()` as its "default" value (that after the `=`) for that function's parameter, without any parameter in `Depends()`, instead of having to write the full class *again* inside of `Depends(CommonQueryParams)`.
-So, the same example would look like:
+The same example would then look like:
```Python hl_lines="19"
{!../../../docs_src/dependencies/tutorial004.py!}
...and **FastAPI** will know what to do.
!!! tip
- If all that seems more confusing than helpful, disregard it, you don't *need* it.
-
+ If that seems more confusing than helpful, disregard it, you don't *need* it.
+
It is just a shortcut. Because **FastAPI** cares about helping you minimize code repetition.
**2 lines**.
-And it has the same shape and structure that all your *path operation functions*.
+And it has the same shape and structure that all your *path operation functions* have.
You can think of it as a *path operation function* without the "decorator" (without the `@app.get("/some-path")`).
<img src="/img/tutorial/dependencies/image01.png">
-
## Simple usage
-If you look at it, *path operation functions* are declared to be used whenever a *path* and *operation* matches, and then **FastAPI** takes care of calling the function with the correct parameters and use the response.
+If you look at it, *path operation functions* are declared to be used whenever a *path* and *operation* matches, and then **FastAPI** takes care of calling the function with the correct parameters, extracting the data from the request.
Actually, all (or most) of the web frameworks work in this same way.
* Even though this function is a dependency ("dependable") itself, it also declares another dependency (it "depends" on something else).
* It depends on the `query_extractor`, and assigns the value returned by it to the parameter `q`.
* It also declares an optional `last_query` cookie, as a `str`.
- * Let's imagine that if the user didn't provide any query `q`, we just use the last query used, that we had saved to a cookie before.
+ * If the user didn't provide any query `q`, we use the last query used, which we saved to a cookie before.
### Use the dependency