From 059793d585f049543396af444226d4851a2aa93a Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Thu, 27 Apr 2023 16:19:02 +0100 Subject: [PATCH] Remove a type: ignore comment GIve the type checker more information about the converters instead. --- fastapi_cache/coder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastapi_cache/coder.py b/fastapi_cache/coder.py index f3df837..da548de 100644 --- a/fastapi_cache/coder.py +++ b/fastapi_cache/coder.py @@ -3,14 +3,14 @@ import datetime import json import pickle # nosec:B403 from decimal import Decimal -from typing import Any +from typing import Any, Callable import pendulum from fastapi.encoders import jsonable_encoder from starlette.responses import JSONResponse from starlette.templating import _TemplateResponse as TemplateResponse -CONVERTERS = { +CONVERTERS: dict[str, Callable[[str], Any]] = { "date": lambda x: pendulum.parse(x, exact=True), "datetime": lambda x: pendulum.parse(x, exact=True), "decimal": Decimal, @@ -35,7 +35,7 @@ def object_hook(obj: Any) -> Any: return obj if _spec_type in CONVERTERS: - return CONVERTERS[_spec_type](obj["val"]) # type: ignore + return CONVERTERS[_spec_type](obj["val"]) else: raise TypeError("Unknown {}".format(_spec_type))