From 7b5deb0261f0deb0cca7841e2569f13735b00d74 Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Wed, 3 Apr 2024 19:20:55 -0600 Subject: [PATCH] mypy --- examples/resources/base.py | 4 ++-- examples/resources/users.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/resources/base.py b/examples/resources/base.py index 221508b..ad8f541 100644 --- a/examples/resources/base.py +++ b/examples/resources/base.py @@ -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!') diff --git a/examples/resources/users.py b/examples/resources/users.py index 8c6498e..de24b3e 100644 --- a/examples/resources/users.py +++ b/examples/resources/users.py @@ -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') @@ -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)