From d219b2f27ca2529d4893d7b4741e1a4bfb60c6c0 Mon Sep 17 00:00:00 2001 From: Gary Gale Date: Mon, 11 Nov 2024 08:29:14 +0000 Subject: [PATCH] build: fix up type hints for #430 --- fastapi_cache/decorator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi_cache/decorator.py b/fastapi_cache/decorator.py index 72d8932..c873668 100644 --- a/fastapi_cache/decorator.py +++ b/fastapi_cache/decorator.py @@ -142,7 +142,7 @@ def cache( # unintuitively, we have to await once here, so that caller # does not have to await twice. See # https://stackoverflow.com/a/59268198/532513 - return await func(*args, **kwargs) + return await func(*args, **kwargs) # type: ignore[no-any-return] else: # sync, wrap in thread and return async # see above why we have to await even although caller also awaits. @@ -221,7 +221,7 @@ def cache( return response result = cast(R, coder.decode_as_type(cached, type_=return_type)) - if isinstance(result, Response): + if response and isinstance(result, Response): result.headers.update(response.headers) return result