Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
rogelioLpz committed Apr 4, 2024
1 parent 6866199 commit 7b5deb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def health_auth_check() -> Dict:


@app.get('/raise_cuenca_errors')
def raise_cuenca_errors() -> None:
def raise_cuenca_errors() -> NoReturn:
raise WrongCredsError('you are not lucky enough!')


@app.get('/raise_fast_agave_errors')
def raise_fast_agave_errors() -> None:
def raise_fast_agave_errors() -> NoReturn:
raise UnauthorizedError('nice try!')


Expand Down
6 changes: 2 additions & 4 deletions examples/resources/users.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from typing import cast

from fast_agave.filters import generic_query
from ..models import User as UserModel
from ..validators import UserQuery, UserUpdateRequest
from .base import app
from fastapi.responses import JSONResponse as Response
from fastapi import Request
from starlette.datastructures import Address


@app.resource('/users')
Expand All @@ -21,6 +18,7 @@ async def update(
user: UserModel, request: UserUpdateRequest, api_request: Request
) -> Response:
user.name = request.name
user.ip = cast(Address, api_request.client).host
assert api_request.client # Only for mypy, client is optional
user.ip = api_request.client.host
await user.async_save()
return Response(content=user.to_dict(), status_code=200)

0 comments on commit 7b5deb0

Please sign in to comment.