mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
Add pyright strict type checking
This commit is contained in:
@@ -41,7 +41,7 @@ class DynamoBackend(Backend):
|
||||
self.region = region
|
||||
|
||||
async def init(self) -> None:
|
||||
self.client = await self.session.create_client(
|
||||
self.client = await self.session.create_client( # pyright: ignore[reportUnknownMemberType]
|
||||
"dynamodb", region_name=self.region
|
||||
).__aenter__()
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ import pendulum
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from pydantic import BaseConfig, ValidationError, fields
|
||||
from starlette.responses import JSONResponse
|
||||
from starlette.templating import _TemplateResponse as TemplateResponse
|
||||
from starlette.templating import (
|
||||
_TemplateResponse as TemplateResponse, # pyright: ignore[reportPrivateUsage]
|
||||
)
|
||||
|
||||
_T = TypeVar("_T", bound=type)
|
||||
|
||||
@@ -22,15 +24,15 @@ CONVERTERS: Dict[str, Callable[[str], Any]] = {
|
||||
|
||||
|
||||
class JsonEncoder(json.JSONEncoder):
|
||||
def default(self, obj: Any) -> Any:
|
||||
if isinstance(obj, datetime.datetime):
|
||||
return {"val": str(obj), "_spec_type": "datetime"}
|
||||
elif isinstance(obj, datetime.date):
|
||||
return {"val": str(obj), "_spec_type": "date"}
|
||||
elif isinstance(obj, Decimal):
|
||||
return {"val": str(obj), "_spec_type": "decimal"}
|
||||
def default(self, o: Any) -> Any:
|
||||
if isinstance(o, datetime.datetime):
|
||||
return {"val": str(o), "_spec_type": "datetime"}
|
||||
elif isinstance(o, datetime.date):
|
||||
return {"val": str(o), "_spec_type": "date"}
|
||||
elif isinstance(o, Decimal):
|
||||
return {"val": str(o), "_spec_type": "decimal"}
|
||||
else:
|
||||
return jsonable_encoder(obj)
|
||||
return jsonable_encoder(o)
|
||||
|
||||
|
||||
def object_hook(obj: Any) -> Any:
|
||||
|
||||
@@ -29,7 +29,7 @@ def _augment_signature(signature: Signature, *extra: Parameter) -> Signature:
|
||||
return signature
|
||||
|
||||
parameters = list(signature.parameters.values())
|
||||
variadic_keyword_params = []
|
||||
variadic_keyword_params: List[Parameter] = []
|
||||
while parameters and parameters[-1].kind is Parameter.VAR_KEYWORD:
|
||||
variadic_keyword_params.append(parameters.pop())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user