From 32429ccdb908ce5ebfe56461b1ca81a4cd0236e4 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 10 Mar 2026 21:56:10 +0100 Subject: [PATCH] juggling between ty and mypy --- fastapi/applications.py | 4 ++-- fastapi/dependencies/utils.py | 4 +--- fastapi/routing.py | 4 ++-- fastapi/security/api_key.py | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/fastapi/applications.py b/fastapi/applications.py index c468d58cc2..916042cf31 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -1010,8 +1010,8 @@ class FastAPI(Starlette): # Starlette still has incorrect type specification for the handlers self.exception_handlers.setdefault( WebSocketRequestValidationError, - websocket_request_validation_exception_handler, - ) # type: ignore + websocket_request_validation_exception_handler, # type: ignore # ty: ignore[unused-ignore-comment] + ) # ty: ignore self.user_middleware: list[Middleware] = ( [] if middleware is None else list(middleware) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 6a5fce6d55..631209da93 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -100,9 +100,7 @@ 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] # ty: ignore[unused-ignore-comment] - ) + from multipart import __version__ assert __version__ try: diff --git a/fastapi/routing.py b/fastapi/routing.py index e31b09474a..ab0ea0b515 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -101,7 +101,7 @@ def request_response( """ f: Callable[[Request], Awaitable[Response]] = ( func if is_async_callable(func) else functools.partial(run_in_threadpool, func) # type:ignore # ty: ignore[unused-ignore-comment] - ) + ) # ty: ignore async def app(scope: Scope, receive: Receive, send: Send) -> None: request = Request(scope, receive, send) @@ -453,7 +453,7 @@ def get_request_handler( solved_result = await solve_dependencies( request=request, dependant=dependant, - body=body, + body=body, # ty: ignore[invalid-argument-type] dependency_overrides_provider=dependency_overrides_provider, async_exit_stack=async_exit_stack, embed_body_fields=embed_body_fields, diff --git a/fastapi/security/api_key.py b/fastapi/security/api_key.py index 8614f4f849..83a4585a08 100644 --- a/fastapi/security/api_key.py +++ b/fastapi/security/api_key.py @@ -22,7 +22,7 @@ class APIKeyBase(SecurityBase): self.auto_error = auto_error self.model: APIKey = APIKey( - **{"in": location}, # type: ignore[invalid-argument-type] + **{"in": location}, # ty: ignore[invalid-argument-type] name=name, description=description, )