---
source: crates/ruff_linter/src/rules/fastapi/mod.rs
---
FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature
  --> FAST003.py:9:19
   |
 8 | # Errors
 9 | @app.get("/things/{thing_id}")
   |                   ^^^^^^^^^^
10 | async def read_thing(query: str):
11 |     return {"query": query}
   |
help: Add `thing_id` to function signature
   |
9  | @app.get("/things/{thing_id}")
   - async def read_thing(query: str):
10 + async def read_thing(query: str, thing_id):
11 |     return {"query": query}
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `isbn` appears in route path, but not in `read_thing` signature
  --> FAST003.py:14:23
   |
14 | @app.get("/books/isbn-{isbn}")
   |                       ^^^^^^
15 | async def read_thing():
16 |     ...
   |
help: Add `isbn` to function signature
   |
14 | @app.get("/books/isbn-{isbn}")
   - async def read_thing():
15 + async def read_thing(isbn):
16 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature
  --> FAST003.py:19:19
   |
19 | @app.get("/things/{thing_id:path}")
   |                   ^^^^^^^^^^^^^^^
20 | async def read_thing(query: str):
21 |     return {"query": query}
   |
help: Add `thing_id` to function signature
   |
19 | @app.get("/things/{thing_id:path}")
   - async def read_thing(query: str):
20 + async def read_thing(query: str, thing_id):
21 |     return {"query": query}
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:29:27
   |
29 | @app.get("/books/{author}/{title}")
   |                           ^^^^^^^
30 | async def read_thing(author: str):
31 |     return {"author": author}
   |
help: Add `title` to function signature
   |
29 | @app.get("/books/{author}/{title}")
   - async def read_thing(author: str):
30 + async def read_thing(author: str, title):
31 |     return {"author": author}
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `author_name` appears in route path, but not in `read_thing` signature
  --> FAST003.py:34:18
   |
34 | @app.get("/books/{author_name}/{title}")
   |                  ^^^^^^^^^^^^^
35 | async def read_thing():
36 |     ...
   |
help: Add `author_name` to function signature
   |
34 | @app.get("/books/{author_name}/{title}")
   - async def read_thing():
35 + async def read_thing(author_name):
36 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:34:32
   |
34 | @app.get("/books/{author_name}/{title}")
   |                                ^^^^^^^
35 | async def read_thing():
36 |     ...
   |
help: Add `title` to function signature
   |
34 | @app.get("/books/{author_name}/{title}")
   - async def read_thing():
35 + async def read_thing(title):
36 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 Parameter `author` appears in route path, but only as a positional-only argument in `read_thing` signature
  --> FAST003.py:39:18
   |
39 | @app.get("/books/{author}/{title}")
   |                  ^^^^^^^^
40 | async def read_thing(author: str, title: str, /):
41 |     return {"author": author, "title": title}
   |

FAST003 Parameter `title` appears in route path, but only as a positional-only argument in `read_thing` signature
  --> FAST003.py:39:27
   |
39 | @app.get("/books/{author}/{title}")
   |                           ^^^^^^^
40 | async def read_thing(author: str, title: str, /):
41 |     return {"author": author, "title": title}
   |

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:44:27
   |
44 | @app.get("/books/{author}/{title}/{page}")
   |                           ^^^^^^^
45 | async def read_thing(
46 |     author: str,
   |
help: Add `title` to function signature
   |
46 |     author: str,
   -     query: str,
47 +     query: str, title,
48 | ): ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `page` appears in route path, but not in `read_thing` signature
  --> FAST003.py:44:35
   |
44 | @app.get("/books/{author}/{title}/{page}")
   |                                   ^^^^^^
45 | async def read_thing(
46 |     author: str,
   |
help: Add `page` to function signature
   |
46 |     author: str,
   -     query: str,
47 +     query: str, page,
48 | ): ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `author` appears in route path, but not in `read_thing` signature
  --> FAST003.py:51:18
   |
51 | @app.get("/books/{author}/{title}")
   |                  ^^^^^^^^
52 | async def read_thing():
53 |     ...
   |
help: Add `author` to function signature
   |
51 | @app.get("/books/{author}/{title}")
   - async def read_thing():
52 + async def read_thing(author):
53 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:51:27
   |
51 | @app.get("/books/{author}/{title}")
   |                           ^^^^^^^
52 | async def read_thing():
53 |     ...
   |
help: Add `title` to function signature
   |
51 | @app.get("/books/{author}/{title}")
   - async def read_thing():
52 + async def read_thing(title):
53 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:56:27
   |
56 | @app.get("/books/{author}/{title}")
   |                           ^^^^^^^
57 | async def read_thing(*, author: str):
58 |     ...
   |
help: Add `title` to function signature
   |
56 | @app.get("/books/{author}/{title}")
   - async def read_thing(*, author: str):
57 + async def read_thing(title, *, author: str):
58 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature
  --> FAST003.py:61:27
   |
61 | @app.get("/books/{author}/{title}")
   |                           ^^^^^^^
62 | async def read_thing(hello, /, *, author: str):
63 |     ...
   |
help: Add `title` to function signature
   |
61 | @app.get("/books/{author}/{title}")
   - async def read_thing(hello, /, *, author: str):
62 + async def read_thing(hello, /, title, *, author: str):
63 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature
  --> FAST003.py:66:19
   |
66 | @app.get("/things/{thing_id}")
   |                   ^^^^^^^^^^
67 | async def read_thing(
68 |         query: str,
   |
help: Add `thing_id` to function signature
   |
67 | async def read_thing(
   -         query: str,
68 +         query: str, thing_id,
69 | ):
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature
  --> FAST003.py:73:19
   |
73 | @app.get("/things/{thing_id}")
   |                   ^^^^^^^^^^
74 | async def read_thing(
75 |         query: str = "default",
   |
help: Add `thing_id` to function signature
   |
74 | async def read_thing(
   -         query: str = "default",
75 +         thing_id, query: str = "default",
76 | ):
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature
  --> FAST003.py:80:19
   |
80 | @app.get("/things/{thing_id}")
   |                   ^^^^^^^^^^
81 | async def read_thing(
82 |         *, query: str = "default",
   |
help: Add `thing_id` to function signature
   |
81 | async def read_thing(
   -         *, query: str = "default",
82 +         thing_id, *, query: str = "default",
83 | ):
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `name` appears in route path, but not in `read_thing` signature
  --> FAST003.py:87:18
   |
87 | @app.get("/books/{name}/{title}")
   |                  ^^^^^^
88 | async def read_thing(*, author: Annotated[str, Path(alias="author_name")], title: str):
89 |     return {"author": author, "title": title}
   |
help: Add `name` to function signature
   |
87 | @app.get("/books/{name}/{title}")
   - async def read_thing(*, author: Annotated[str, Path(alias="author_name")], title: str):
88 + async def read_thing(name, *, author: Annotated[str, Path(alias="author_name")], title: str):
89 |     return {"author": author, "title": title}
   |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `default` signature
   --> FAST003.py:160:19
    |
158 | @app.get("/things/{thing_id}")
159 | async def single(other: Annotated[str, Depends(something_else)]): ...
160 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
161 | async def default(other: str = Depends(something_else)): ...
    |
help: Add `thing_id` to function signature
    |
160 | @app.get("/things/{thing_id}")
    - async def default(other: str = Depends(something_else)): ...
161 + async def default(thing_id, other: str = Depends(something_else)): ...
162 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `id` appears in route path, but not in `get_id_init_not_annotated` signature
   --> FAST003.py:203:12
    |
201 | @app.get("/{id}")
202 | async def get_id_pydantic_short(params: Annotated[PydanticParams, Depends()]): ...
203 | @app.get("/{id}")
    |            ^^^^
204 | async def get_id_init_not_annotated(params = Depends(InitParams)): ...
    |
help: Add `id` to function signature
    |
203 | @app.get("/{id}")
    - async def get_id_init_not_annotated(params = Depends(InitParams)): ...
204 + async def get_id_init_not_annotated(id, params = Depends(InitParams)): ...
205 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 Parameter `import` appears in route path, but not in `get_import` signature
   --> FAST003.py:266:20
    |
265 | # https://github.com/astral-sh/ruff/issues/20941
266 | @app.get("/imports/{import}")
    |                    ^^^^^^^^
267 | async def get_import():
268 |     ...
    |
help: Add `import` to function signature

FAST003 Parameter `__debug__` appears in route path, but not in `get_debug` signature
   --> FAST003.py:270:18
    |
268 |     ...
269 |
270 | @app.get("/debug/{__debug__}")
    |                  ^^^^^^^^^^^
271 | async def get_debug():
272 |     ...
    |
help: Add `__debug__` to function signature

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_vararg` signature
   --> FAST003.py:278:19
    |
277 | # Errors: vararg-only and kwarg-only functions
278 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
279 | async def read_thing_vararg(*query: str): ...
    |
help: Add `thing_id` to function signature
    |
278 | @app.get("/things/{thing_id}")
    - async def read_thing_vararg(*query: str): ...
279 + async def read_thing_vararg(thing_id, *query: str): ...
280 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_kwarg` signature
   --> FAST003.py:281:19
    |
279 | async def read_thing_vararg(*query: str): ...
280 |
281 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
282 | async def read_thing_kwarg(**query: str): ...
    |
help: Add `thing_id` to function signature
    |
281 | @app.get("/things/{thing_id}")
    - async def read_thing_kwarg(**query: str): ...
282 + async def read_thing_kwarg(thing_id, **query: str): ...
283 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_vararg_kwarg` signature
   --> FAST003.py:284:19
    |
282 | async def read_thing_kwarg(**query: str): ...
283 |
284 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
285 | async def read_thing_vararg_kwarg(*args, **kwargs): ...
    |
help: Add `thing_id` to function signature
    |
284 | @app.get("/things/{thing_id}")
    - async def read_thing_vararg_kwarg(*args, **kwargs): ...
285 + async def read_thing_vararg_kwarg(thing_id, *args, **kwargs): ...
286 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_posonly` signature
   --> FAST003.py:288:19
    |
287 | # Errors: positional-only parameter edge cases
288 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
289 | async def read_thing_posonly(query: str, /): ...
    |
help: Add `thing_id` to function signature
    |
288 | @app.get("/things/{thing_id}")
    - async def read_thing_posonly(query: str, /): ...
289 + async def read_thing_posonly(query: str, /, thing_id): ...
290 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_posonly_trailing` signature
   --> FAST003.py:291:19
    |
289 | async def read_thing_posonly(query: str, /): ...
290 |
291 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
292 | async def read_thing_posonly_trailing(query: str, /,): ...
    |
help: Add `thing_id` to function signature
    |
291 | @app.get("/things/{thing_id}")
    - async def read_thing_posonly_trailing(query: str, /,): ...
292 + async def read_thing_posonly_trailing(query: str, /, thing_id,): ...
293 |
    |
note: This is an unsafe fix and may change runtime behavior

FAST003 Parameter `thing_id` appears in route path, but not in `read_thing_posonly_default` signature
   --> FAST003.py:294:19
    |
292 | async def read_thing_posonly_trailing(query: str, /,): ...
293 |
294 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
295 | async def read_thing_posonly_default(query: str = "", /): ...
    |
help: Add `thing_id` to function signature

FAST003 Parameter `thing_id` appears in route path, but not in `read_thing_posonly_default_trailing` signature
   --> FAST003.py:297:19
    |
295 | async def read_thing_posonly_default(query: str = "", /): ...
296 |
297 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
298 | async def read_thing_posonly_default_trailing(query: str = "", /,): ...
    |
help: Add `thing_id` to function signature

FAST003 Parameter `thing_id` appears in route path, but not in `read_thing_posonly_with_regular` signature
   --> FAST003.py:300:19
    |
298 | async def read_thing_posonly_default_trailing(query: str = "", /,): ...
299 |
300 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
301 | async def read_thing_posonly_with_regular(query: str = "", /, x=None): ...
    |
help: Add `thing_id` to function signature

FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing_init_and_call_instance_default` signature
   --> FAST003.py:370:19
    |
368 | async def read_thing_callable_dep_instance_default(query: str = Depends(CallableQuery())): ...
369 | # Error: `__call__` has `other`, not `thing_id`.
370 | @app.get("/things/{thing_id}")
    |                   ^^^^^^^^^^
371 | async def read_thing_init_and_call_instance_default(query: str = Depends(InitAndCallQuery())): ...
    |
help: Add `thing_id` to function signature
    |
370 | @app.get("/things/{thing_id}")
    - async def read_thing_init_and_call_instance_default(query: str = Depends(InitAndCallQuery())): ...
371 + async def read_thing_init_and_call_instance_default(thing_id, query: str = Depends(InitAndCallQuery())): ...
    |
note: This is an unsafe fix and may change runtime behavior
