From dffac8bb2c44e8a56c4082f7b13a0bb70f7a8d20 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:35:13 +0400 Subject: [PATCH] [Backport 8.15] Fix aiohttp call type: ignore differently (#193) (cherry picked from commit d50788d6afb278739dc11a6842fae8602a8ea791) Co-authored-by: Quentin Pradet --- elastic_transport/_node/_http_aiohttp.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/elastic_transport/_node/_http_aiohttp.py b/elastic_transport/_node/_http_aiohttp.py index b75aa86..68f5000 100644 --- a/elastic_transport/_node/_http_aiohttp.py +++ b/elastic_transport/_node/_http_aiohttp.py @@ -23,7 +23,7 @@ import re import ssl import warnings -from typing import Any, MutableMapping, Optional, Union +from typing import Optional, TypedDict, Union from .._compat import warn_stacklevel from .._exceptions import ConnectionError, ConnectionTimeout, SecurityWarning, TlsError @@ -55,6 +55,10 @@ # See aio-libs/aiohttp#1769 and #5012 _AIOHTTP_FIXED_HEAD_BUG = _AIOHTTP_SEMVER_VERSION >= (3, 7, 0) + + class RequestKwarg(TypedDict, total=False): + ssl: aiohttp.Fingerprint + except ImportError: # pragma: nocover _AIOHTTP_AVAILABLE = False _AIOHTTP_META_VERSION = "" @@ -170,7 +174,7 @@ async def perform_request( # type: ignore[override] else: body_to_send = None - kwargs: MutableMapping[str, Any] = {} + kwargs: RequestKwarg = {} if self._ssl_assert_fingerprint: kwargs["ssl"] = aiohttp_fingerprint(self._ssl_assert_fingerprint) @@ -182,7 +186,7 @@ async def perform_request( # type: ignore[override] data=body_to_send, headers=request_headers, timeout=aiohttp_timeout, - **kwargs, # type: ignore[arg-type] + **kwargs, ) as response: if is_head: # We actually called 'GET' so throw away the data. await response.release()