-
Couldn't load subscription status.
- Fork 1.6k
Open
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
A full reproduction can be seen at: https://github.com/vinnybod/reproductions/tree/vinnybod/FAST003
TL;DR:
If using thing=Depends(get_thing), the route path parameter thing_id is found in the get_thing dependency.
If using the equivalent thing: ThingDep, the route path parameter is considered missing by the FAST003 rule.
from typing import Annotated
from fastapi import FastAPI, Depends
app = FastAPI()
async def get_thing(thing_id: int):
return {"thing_id": thing_id}
ThingDep = Annotated[dict, Depends(get_thing)]
# This is considered wrong by FAST003
@app.get("annotated/{thing_id}")
async def get_thing_endpoint(thing: ThingDep):
return thing
# This is considered fine by FAST003
@app.get("depends/{thing_id}")
async def get_thing_endpoint(thing=Depends(get_thing)):
return thing> poetry run ruff check . --fix
FAST003 Parameter `thing_id` appears in route path, but not in `get_thing_endpoint` signature
--> reproductions/main.py:16:21
|
15 | # This is considered wrong by FAST003
16 | @app.get("annotated/{thing_id}")
| ^^^^^^^^^^
17 | async def get_thing_endpoint(thing: ThingDep):
18 | return thing
|
help: Add `thing_id` to function signature
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
Version
ruff 0.14.1 (2bffef5 2025-10-16)
Metadata
Metadata
Assignees
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule