From 8491eee34034f0860d968dd3e17a3e85b5d53b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 17 Dec 2025 22:20:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Tweak=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/_compat/shared.py | 4 ++-- fastapi/_compat/v2.py | 2 +- fastapi/dependencies/utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fastapi/_compat/shared.py b/fastapi/_compat/shared.py index a82eeba08..3a11e88ac 100644 --- a/fastapi/_compat/shared.py +++ b/fastapi/_compat/shared.py @@ -60,7 +60,7 @@ def lenient_issubclass( def _annotation_is_sequence(annotation: Union[type[Any], None]) -> bool: if lenient_issubclass(annotation, (str, bytes)): return False - return lenient_issubclass(annotation, sequence_types) # type: ignore[arg-type] + return lenient_issubclass(annotation, sequence_types) def field_annotation_is_sequence(annotation: Union[type[Any], None]) -> bool: @@ -76,7 +76,7 @@ def field_annotation_is_sequence(annotation: Union[type[Any], None]) -> bool: def value_is_sequence(value: Any) -> bool: - return isinstance(value, sequence_types) and not isinstance(value, (str, bytes)) # type: ignore[arg-type] + return isinstance(value, sequence_types) and not isinstance(value, (str, bytes)) def _annotation_is_complex(annotation: Union[type[Any], None]) -> bool: diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 9456873dd..c4fa49e40 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -457,7 +457,7 @@ def serialize_sequence_value(*, field: ModelField, value: Any) -> Sequence[Any]: origin_type = get_origin(union_arg) or union_arg break assert issubclass(origin_type, shared.sequence_types) # type: ignore[arg-type] - return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return] + return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return,index] def get_missing_field_error(loc: tuple[str, ...]) -> dict[str, Any]: diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 5a461c505..3db006a91 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -915,7 +915,7 @@ async def _extract_form_body( and value_is_sequence(value) ): # For types - assert isinstance(value, sequence_types) # type: ignore[arg-type] + assert isinstance(value, sequence_types) results: list[Union[bytes, str]] = [] async def process_fn(