Skip to content

Commit

Permalink
Per review
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jan 9, 2025
1 parent 9b348aa commit e7f81da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions crates/ruff_linter/resources/test/fixtures/fastapi/FAST003.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,29 @@ async def read_thing(query: str):


# https://github.com/astral-sh/ruff/issues/13657
def dependable(thing_id): ...
def not_so_dependable(lorem): ...
def takes_thing_id(thing_id): ...
def something_else(lorem): ...

from foo import unknown_imported
unknown_not_function = unknown_imported()


### Errors
@app.get("/things/{thing_id}")
async def single(other: Annotated[str, Depends(not_so_dependable)]): ...
async def single(other: Annotated[str, Depends(something_else)]): ...
@app.get("/things/{thing_id}")
async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
@app.get("/things/{thing_id}")
async def default(other: str = Depends(not_so_dependable)): ...
async def default(other: str = Depends(something_else)): ...


### No errors
@app.get("/things/{thing_id}")
async def single(other: Annotated[str, Depends(dependable)]): ...
async def single(other: Annotated[str, Depends(takes_thing_id)]): ...
@app.get("/things/{thing_id}")
async def double(other: Annotated[str, Depends(dependable), Depends(not_so_dependable)]): ...
async def double(other: Annotated[str, Depends(takes_thing_id), Depends(something_else)]): ...
@app.get("/things/{thing_id}")
async def default(other: str = Depends(dependable)): ...
async def default(other: str = Depends(takes_thing_id)): ...
@app.get("/things/{thing_id}")
async def unknown_1(other: str = Depends(unknown_unresolved)): ...
@app.get("/things/{thing_id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ FAST003.py:158:19: FAST003 [*] Parameter `thing_id` appears in route path, but n
157 | ### Errors
158 | @app.get("/things/{thing_id}")
| ^^^^^^^^^^ FAST003
159 | async def single(other: Annotated[str, Depends(not_so_dependable)]): ...
159 | async def single(other: Annotated[str, Depends(something_else)]): ...
160 | @app.get("/things/{thing_id}")
|
= help: Add `thing_id` to function signature
Expand All @@ -356,49 +356,49 @@ FAST003.py:158:19: FAST003 [*] Parameter `thing_id` appears in route path, but n
156 156 |
157 157 | ### Errors
158 158 | @app.get("/things/{thing_id}")
159 |-async def single(other: Annotated[str, Depends(not_so_dependable)]): ...
159 |+async def single(other: Annotated[str, Depends(not_so_dependable)], thing_id): ...
159 |-async def single(other: Annotated[str, Depends(something_else)]): ...
159 |+async def single(other: Annotated[str, Depends(something_else)], thing_id): ...
160 160 | @app.get("/things/{thing_id}")
161 161 | async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
161 161 | async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
162 162 | @app.get("/things/{thing_id}")

FAST003.py:160:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `double` signature
|
158 | @app.get("/things/{thing_id}")
159 | async def single(other: Annotated[str, Depends(not_so_dependable)]): ...
159 | async def single(other: Annotated[str, Depends(something_else)]): ...
160 | @app.get("/things/{thing_id}")
| ^^^^^^^^^^ FAST003
161 | async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
161 | async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
162 | @app.get("/things/{thing_id}")
|
= help: Add `thing_id` to function signature

ℹ Unsafe fix
158 158 | @app.get("/things/{thing_id}")
159 159 | async def single(other: Annotated[str, Depends(not_so_dependable)]): ...
159 159 | async def single(other: Annotated[str, Depends(something_else)]): ...
160 160 | @app.get("/things/{thing_id}")
161 |-async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
161 |+async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)], thing_id): ...
161 |-async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
161 |+async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)], thing_id): ...
162 162 | @app.get("/things/{thing_id}")
163 163 | async def default(other: str = Depends(not_so_dependable)): ...
163 163 | async def default(other: str = Depends(something_else)): ...
164 164 |

FAST003.py:162:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `default` signature
|
160 | @app.get("/things/{thing_id}")
161 | async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
161 | async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
162 | @app.get("/things/{thing_id}")
| ^^^^^^^^^^ FAST003
163 | async def default(other: str = Depends(not_so_dependable)): ...
163 | async def default(other: str = Depends(something_else)): ...
|
= help: Add `thing_id` to function signature

ℹ Unsafe fix
160 160 | @app.get("/things/{thing_id}")
161 161 | async def double(other: Annotated[str, Depends(not_so_dependable), Depends(dependable)]): ...
161 161 | async def double(other: Annotated[str, Depends(something_else), Depends(takes_thing_id)]): ...
162 162 | @app.get("/things/{thing_id}")
163 |-async def default(other: str = Depends(not_so_dependable)): ...
163 |+async def default(thing_id, other: str = Depends(not_so_dependable)): ...
163 |-async def default(other: str = Depends(something_else)): ...
163 |+async def default(thing_id, other: str = Depends(something_else)): ...
164 164 |
165 165 |
166 166 | ### No errors

0 comments on commit e7f81da

Please sign in to comment.