Coverage for docs_src / dependencies / tutorial011_an_py310.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from typing import Annotated 1abcdefg

2 

3from fastapi import Depends, FastAPI 1abcdefg

4 

5app = FastAPI() 1abcdefg

6 

7 

8class FixedContentQueryChecker: 1abcdefg

9 def __init__(self, fixed_content: str): 1abcdefg

10 self.fixed_content = fixed_content 1abcdefg

11 

12 def __call__(self, q: str = ""): 1abcdefg

13 if q: 1hijklmnopqr

14 return self.fixed_content in q 1ijlnoqr

15 return False 1hkmp

16 

17 

18checker = FixedContentQueryChecker("bar") 1abcdefg

19 

20 

21@app.get("/query-checker/") 1abcdefg

22async def read_query_check(fixed_content_included: Annotated[bool, Depends(checker)]): 1abcdefg

23 return {"fixed_content_in_query": fixed_content_included} 1hijklmnopqr