---
source: crates/ruff_linter/src/rules/fastapi/mod.rs
---
FAST002 [*] FastAPI dependency without `Annotated`
  --> FAST002_1.py:10:13
   |
 9 | @app.get("/test")
10 | def handler(echo: str = Query("")):
   |             ^^^^^^^^^^^^^^^^^^^^^
11 |     return echo
   |
help: Replace with `typing_extensions.Annotated`
   |
4  | from fastapi import FastAPI, Query
5  + from typing_extensions import Annotated
6  |
--------------------------------------------------------------------------------
10 | @app.get("/test")
   - def handler(echo: str = Query("")):
11 + def handler(echo: Annotated[str, Query()] = ""):
12 |     return echo
   |
note: This is an unsafe fix and may change runtime behavior

FAST002 [*] FastAPI dependency without `Annotated`
  --> FAST002_1.py:15:14
   |
14 | @app.get("/test")
15 | def handler2(echo: str = Query(default="")):
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 |     return echo
   |
help: Replace with `typing_extensions.Annotated`
   |
4  | from fastapi import FastAPI, Query
5  + from typing_extensions import Annotated
6  |
--------------------------------------------------------------------------------
15 | @app.get("/test")
   - def handler2(echo: str = Query(default="")):
16 + def handler2(echo: Annotated[str, Query()] = ""):
17 |     return echo
   |
note: This is an unsafe fix and may change runtime behavior

FAST002 [*] FastAPI dependency without `Annotated`
  --> FAST002_1.py:20:14
   |
19 | @app.get("/test")
20 | def handler3(echo: str = Query("123", min_length=3, max_length=50)):
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |     return echo
   |
help: Replace with `typing_extensions.Annotated`
   |
4  | from fastapi import FastAPI, Query
5  + from typing_extensions import Annotated
6  |
--------------------------------------------------------------------------------
20 | @app.get("/test")
   - def handler3(echo: str = Query("123", min_length=3, max_length=50)):
21 + def handler3(echo: Annotated[str, Query(min_length=3, max_length=50)] = "123"):
22 |     return echo
   |
note: This is an unsafe fix and may change runtime behavior
