You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromfastapiimportFastAPIdefsetup_app(app: FastAPI) ->None:
@app.get("/")asyncdefget_root() ->str: # RUF029 herereturn"Hello World!"app=FastAPI()
@app.get("/foo")asyncdefget_foo() ->str: # no errorreturn"Hello this is foo"
Note that it doesn't trigger on the top-level function.
That's because there is special handling in the code for FastAPI, implemented by @TomerBin in #12925/#12938, but I guess the underlying cause for the different outcome is that one of the is_fastapi_* checks in rules/fastapi/rules/mod.rs doesn't detect this case correctly.
The text was updated successfully, but these errors were encountered:
scy
added a commit
to AKVorrat/dearmep
that referenced
this issue
Dec 11, 2024
There is special handling in Ruff for FastAPI routes, but it's
apparently not recognizing this function as being one. I've opened
<astral-sh/ruff#14903> for it.
Signed-off-by: Tim Weber <[email protected]>
Hi @scy
Thanks for pointing that out :)
A complete solution will depend on a proper type checking in ruff, but until it'll be landed I can improve the current logic to also detect fastapi routes whose app comes from a function typed argument.
The following code triggers
RUF029
(unused async):Note that it doesn't trigger on the top-level function.
That's because there is special handling in the code for FastAPI, implemented by @TomerBin in #12925/#12938, but I guess the underlying cause for the different outcome is that one of the
is_fastapi_*
checks inrules/fastapi/rules/mod.rs
doesn't detect this case correctly.The text was updated successfully, but these errors were encountered: