Browse Source
Co-authored-by: lokidev <[email protected]> Co-authored-by: Motov Yurii <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Yurii Motov <[email protected]> Co-authored-by: Sebastián Ramírez <[email protected]>pull/14840/head
committed by
GitHub
4 changed files with 34 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
from typing import Annotated |
|||
|
|||
from fastapi import Depends, FastAPI |
|||
from fastapi.testclient import TestClient |
|||
from typing_extensions import TypeAliasType |
|||
|
|||
|
|||
async def some_value() -> int: |
|||
return 123 |
|||
|
|||
|
|||
DependedValue = TypeAliasType( |
|||
"DependedValue", Annotated[int, Depends(some_value)], type_params=() |
|||
) |
|||
|
|||
|
|||
def test_pep695_type_dependencies(): |
|||
app = FastAPI() |
|||
|
|||
@app.get("/") |
|||
async def get_with_dep(value: DependedValue) -> str: # noqa |
|||
return f"value: {value}" |
|||
|
|||
client = TestClient(app) |
|||
response = client.get("/") |
|||
assert response.status_code == 200 |
|||
assert response.text == '"value: 123"' |
|||
Loading…
Reference in new issue