From 6a6cc5c7d4c5a8cf70cfb005f273d54215669c02 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 11 May 2026 16:40:47 +0200 Subject: [PATCH] more type fixes --- fastapi/encoders.py | 4 ++-- fastapi/openapi/utils.py | 2 +- fastapi/params.py | 8 ++++---- fastapi/responses.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fastapi/encoders.py b/fastapi/encoders.py index ceb4c751f4..c9f882d2ba 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -237,9 +237,9 @@ def jsonable_encoder( if isinstance(obj, encoder_type): return encoder_instance(obj) if include is not None and not isinstance(include, (set, dict)): - include = set(include) # type: ignore[assignment] + include = set(include) # type: ignore[assignment] # ty: ignore[invalid-assignment] if exclude is not None and not isinstance(exclude, (set, dict)): - exclude = set(exclude) # type: ignore[assignment] + exclude = set(exclude) # type: ignore[assignment] # ty: ignore[invalid-assignment] if isinstance(obj, BaseModel): obj_dict = obj.model_dump( mode="json", diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index fa6633c7f6..1c7a17c4ca 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -603,4 +603,4 @@ def get_openapi( output["tags"] = tags if external_docs: output["externalDocs"] = external_docs - return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore + return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore[no-any-return] diff --git a/fastapi/params.py b/fastapi/params.py index e684ea8a71..d3f2ae175b 100644 --- a/fastapi/params.py +++ b/fastapi/params.py @@ -23,7 +23,7 @@ class ParamTypes(Enum): cookie = "cookie" -class Param(FieldInfo): # type: ignore[misc] +class Param(FieldInfo): # type: ignore[misc] # ty: ignore[subclass-of-final-class] in_: ParamTypes def __init__( @@ -128,7 +128,7 @@ class Param(FieldInfo): # type: ignore[misc] use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset} - super().__init__(**use_kwargs) + super().__init__(**use_kwargs) # ty: ignore[invalid-argument-type] def __repr__(self) -> str: return f"{self.__class__.__name__}({self.default})" @@ -466,7 +466,7 @@ class Cookie(Param): # type: ignore[misc] ) -class Body(FieldInfo): # type: ignore[misc] +class Body(FieldInfo): # type: ignore[misc] # ty: ignore[subclass-of-final-class] def __init__( self, default: Any = Undefined, @@ -572,7 +572,7 @@ class Body(FieldInfo): # type: ignore[misc] use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset} - super().__init__(**use_kwargs) + super().__init__(**use_kwargs) # ty: ignore[invalid-argument-type] def __repr__(self) -> str: return f"{self.__class__.__name__}({self.default})" diff --git a/fastapi/responses.py b/fastapi/responses.py index 8a7fe262ba..29df4b7a61 100644 --- a/fastapi/responses.py +++ b/fastapi/responses.py @@ -27,13 +27,13 @@ class _OrjsonModule(Protocol): try: ujson = cast(_UjsonModule, importlib.import_module("ujson")) except ModuleNotFoundError: # pragma: nocover - ujson = None # type: ignore + ujson = None # type: ignore[assignment] try: orjson = cast(_OrjsonModule, importlib.import_module("orjson")) except ModuleNotFoundError: # pragma: nocover - orjson = None # type: ignore + orjson = None # type: ignore[assignment] @deprecated(