The following code triggers RUF029 (unused async):
from fastapi import FastAPI
def setup_app(app: FastAPI) -> None:
@app.get("/")
async def get_root() -> str: # RUF029 here
return "Hello World!"
app = FastAPI()
@app.get("/foo")
async def get_foo() -> str: # no error
return "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.