A FastAPI route gives response_model the same type as its return annotation, which FastAPI already uses
What it finds
FastAPI takes the response model from the handler's return annotation. Repeating it in response_model= says the same twice, and the two drift apart when only one is changed.
From the rule's source, redundant_response_model.rs.
from fastapi import FastAPI app = FastAPI() @app.get("/user", response_model=User)tx0 reports: the return annotation already gives this response modeldef user() -> User: return load() @app.get("/public", response_model=PublicUser)def public() -> User: return load() Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:redundant-response-model" = "note"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:redundant-response-model] reason="..."tx0 explain tx0/python:redundant-response-model shows the same in the terminal. Found a false positive? Report it.