From b0c717b797325b53726f9071fb503fa44416985e Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 10 Mar 2026 20:27:23 +0100 Subject: [PATCH] ignore unused ignore's --- fastapi/_compat/v2.py | 4 ++-- fastapi/applications.py | 2 +- fastapi/cli.py | 2 +- fastapi/dependencies/utils.py | 6 +++--- fastapi/encoders.py | 4 ++-- fastapi/openapi/models.py | 2 +- fastapi/openapi/utils.py | 2 +- fastapi/params.py | 12 ++++++------ fastapi/routing.py | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 50b5809693..d2d2f3dbb2 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -22,7 +22,7 @@ from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, create_model from pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationError from pydantic import PydanticUndefinedAnnotation as PydanticUndefinedAnnotation from pydantic import ValidationError as ValidationError -from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined] +from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined] # ty: ignore[unused-ignore-comment] GetJsonSchemaHandler as GetJsonSchemaHandler, ) from pydantic._internal._typing_extra import eval_type_lenient # ty: ignore[deprecated] @@ -438,7 +438,7 @@ def get_flat_models_from_annotation( for arg in get_args(annotation): if lenient_issubclass(arg, (BaseModel, Enum)): if arg not in known_models: - known_models.add(arg) # type: ignore[arg-type] + known_models.add(arg) # type: ignore[arg-type] # ty: ignore[unused-ignore-comment] if lenient_issubclass(arg, BaseModel): get_flat_models_from_model(arg, known_models=known_models) else: diff --git a/fastapi/applications.py b/fastapi/applications.py index e7e816c2e9..e702a494e9 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -1009,7 +1009,7 @@ class FastAPI(Starlette): self.exception_handlers.setdefault( WebSocketRequestValidationError, # Starlette still has incorrect type specification for the handlers - websocket_request_validation_exception_handler, # type: ignore + websocket_request_validation_exception_handler, # type: ignore # ty: ignore[unused-ignore-comment] ) self.user_middleware: list[Middleware] = ( diff --git a/fastapi/cli.py b/fastapi/cli.py index 8d3301e9da..fda271a53a 100644 --- a/fastapi/cli.py +++ b/fastapi/cli.py @@ -6,7 +6,7 @@ except ImportError: # pragma: no cover def main() -> None: - if not cli_main: # type: ignore[truthy-function] + if not cli_main: # type: ignore[truthy-function] # ty: ignore[unused-ignore-comment] message = 'To use the fastapi command, please install "fastapi[standard]":\n\n\tpip install "fastapi[standard]"\n' print(message) raise RuntimeError(message) # noqa: B904 diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 8fcf1a5b3c..74baa243bf 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -100,12 +100,12 @@ def ensure_multipart_is_installed() -> None: except (ImportError, AssertionError): try: # __version__ is available in both multiparts, and can be mocked - from multipart import __version__ # type: ignore[no-redef,import-untyped] + from multipart import __version__ # type: ignore[no-redef,import-untyped] # ty: ignore[unused-ignore-comment] assert __version__ try: # parse_options_header is only available in the right multipart - from multipart.multipart import ( # type: ignore[import-untyped] + from multipart.multipart import ( # type: ignore[import-untyped] # ty: ignore[unused-ignore-comment] parse_options_header, ) @@ -619,7 +619,7 @@ async def solve_dependencies( if response is None: response = Response() del response.headers["content-length"] - response.status_code = None # type: ignore + response.status_code = None # type: ignore # ty: ignore[unused-ignore-comment] if dependency_cache is None: dependency_cache = {} for sub_dependant in dependant.dependencies: diff --git a/fastapi/encoders.py b/fastapi/encoders.py index e20255c110..eafc99f631 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -220,9 +220,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[unused-ignore-comment] 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[unused-ignore-comment] if isinstance(obj, BaseModel): obj_dict = obj.model_dump( mode="json", diff --git a/fastapi/openapi/models.py b/fastapi/openapi/models.py index d7950241fc..b9fad31a70 100644 --- a/fastapi/openapi/models.py +++ b/fastapi/openapi/models.py @@ -20,7 +20,7 @@ try: from pydantic import EmailStr except ImportError: # pragma: no cover - class EmailStr(str): # type: ignore + class EmailStr(str): # type: ignore # ty: ignore[unused-ignore-comment] @classmethod def __get_validators__(cls) -> Iterable[Callable[..., Any]]: yield cls.validate diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index 828442559b..e6e27820e7 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -606,4 +606,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 # ty: ignore[unused-ignore-comment] diff --git a/fastapi/params.py b/fastapi/params.py index 68f9870810..ab5e7ee333 100644 --- a/fastapi/params.py +++ b/fastapi/params.py @@ -135,7 +135,7 @@ class Param(FieldInfo): # type: ignore[misc] return f"{self.__class__.__name__}({self.default})" -class Path(Param): # type: ignore[misc] +class Path(Param): # type: ignore[misc] # ty: ignore[unused-ignore-comment] in_ = ParamTypes.path def __init__( @@ -219,7 +219,7 @@ class Path(Param): # type: ignore[misc] ) -class Query(Param): # type: ignore[misc] +class Query(Param): # type: ignore[misc] # ty: ignore[unused-ignore-comment] in_ = ParamTypes.query def __init__( @@ -301,7 +301,7 @@ class Query(Param): # type: ignore[misc] ) -class Header(Param): # type: ignore[misc] +class Header(Param): # type: ignore[misc] # ty: ignore[unused-ignore-comment] in_ = ParamTypes.header def __init__( @@ -385,7 +385,7 @@ class Header(Param): # type: ignore[misc] ) -class Cookie(Param): # type: ignore[misc] +class Cookie(Param): # type: ignore[misc] # ty: ignore[unused-ignore-comment] in_ = ParamTypes.cookie def __init__( @@ -579,7 +579,7 @@ class Body(FieldInfo): # type: ignore[misc] return f"{self.__class__.__name__}({self.default})" -class Form(Body): # type: ignore[misc] +class Form(Body): # type: ignore[misc] # ty: ignore[unused-ignore-comment] def __init__( self, default: Any = Undefined, @@ -661,7 +661,7 @@ class Form(Body): # type: ignore[misc] ) -class File(Form): # type: ignore[misc] +class File(Form): # type: ignore[misc] # ty: ignore[unused-ignore-comment] def __init__( self, default: Any = Undefined, diff --git a/fastapi/routing.py b/fastapi/routing.py index e2c83aa7b3..c465538e98 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -100,7 +100,7 @@ def request_response( and returns an ASGI application. """ f: Callable[[Request], Awaitable[Response]] = ( - func if is_async_callable(func) else functools.partial(run_in_threadpool, func) # type:ignore + func if is_async_callable(func) else functools.partial(run_in_threadpool, func) # type:ignore # ty: ignore[unused-ignore-comment] ) async def app(scope: Scope, receive: Receive, send: Send) -> None: @@ -908,7 +908,7 @@ class APIRoute(routing.Route): mode="serialization", ) else: - self.response_field = None # type: ignore + self.response_field = None # type: ignore # ty: ignore[unused-ignore-comment] if self.stream_item_type: stream_item_name = "StreamItem_" + self.unique_id self.stream_item_field: ModelField | None = create_model_field(