Annotated
noun
say it: “AN-uh-tay-tid” /ˈænəˌteɪtɪd/
A type hint from Python's typing module that adds extra information to a type, such as Annotated[int, Query(ge=1)], which FastAPI reads as rules.
What is Annotated?
Annotated attaches extra information (like Query(...) or Depends(...)) to a type hint. It is the recommended way to declare parameters.
from typing import Annotated
@app.get('/search')
def search(q: Annotated[str, Query(min_length=2)]):
...
In a sentence
- “FastAPI recommends Annotated for parameters with rules or dependencies.”
- “players: Annotated[int, Query(ge=1)] lets FastAPI refuse 0 players.”
Level: Journeyman · More FastAPI terms at this level
Updated