diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 7f1f244639a..851ab220b8a 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -462,7 +462,7 @@ def update_cookies(self, cookies: Optional[LooseCookies]) -> None: if not cookies: return - c: SimpleCookie[str] = SimpleCookie() + c = SimpleCookie() if hdrs.COOKIE in self.headers: c.load(self.headers.get(hdrs.COOKIE, "")) del self.headers[hdrs.COOKIE] @@ -789,7 +789,7 @@ def __init__( assert isinstance(url, URL) self.method = method - self.cookies: SimpleCookie[str] = SimpleCookie() + self.cookies = SimpleCookie() self._real_url = url self._url = url.with_fragment(None) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 7683b748e44..d85679f8bca 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -248,7 +248,7 @@ def __init__( self._loop = loop self._factory = functools.partial(ResponseHandler, loop=loop) - self.cookies: SimpleCookie[str] = SimpleCookie() + self.cookies = SimpleCookie() # start keep-alive connection cleanup task self._cleanup_handle: Optional[asyncio.TimerHandle] = None diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py index 372a0e7b723..389f4bf1c2b 100644 --- a/aiohttp/cookiejar.py +++ b/aiohttp/cookiejar.py @@ -65,7 +65,7 @@ def __init__( loop: Optional[asyncio.AbstractEventLoop] = None, ) -> None: super().__init__(loop=loop) - self._cookies: DefaultDict[Tuple[str, str], SimpleCookie[str]] = defaultdict( + self._cookies: DefaultDict[Tuple[str, str], SimpleCookie] = defaultdict( SimpleCookie ) self._host_only_cookies: Set[Tuple[str, str]] = set() @@ -168,7 +168,7 @@ def update_cookies(self, cookies: LooseCookies, response_url: URL = URL()) -> No for name, cookie in cookies: if not isinstance(cookie, Morsel): - tmp: SimpleCookie[str] = SimpleCookie() + tmp = SimpleCookie() tmp[name] = cookie # type: ignore[assignment] cookie = tmp[name] @@ -232,11 +232,9 @@ def update_cookies(self, cookies: LooseCookies, response_url: URL = URL()) -> No self._do_expiration() - def filter_cookies( - self, request_url: URL = URL() - ) -> Union["BaseCookie[str]", "SimpleCookie[str]"]: + def filter_cookies(self, request_url: URL = URL()) -> "BaseCookie[str]": """Returns this jar's cookies filtered by their attributes.""" - filtered: Union["SimpleCookie[str]", "BaseCookie[str]"] = ( + filtered: Union[SimpleCookie, "BaseCookie[str]"] = ( SimpleCookie() if self._quote_cookie else BaseCookie() ) if not self._cookies: diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py index 531ce93fccc..6c17b1e7e89 100644 --- a/aiohttp/resolver.py +++ b/aiohttp/resolver.py @@ -45,7 +45,7 @@ async def resolve( # IPv6 is not supported by Python build, # or IPv6 is not enabled in the host continue - if address[3]: # type: ignore[misc] + if address[3]: # This is essential for link-local IPv6 addresses. # LL IPv6 is a VERY rare case. Strictly speaking, we should use # getnameinfo() unconditionally, but performance makes sense. diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py index b4fc9cb0481..a7e32ca6c79 100644 --- a/aiohttp/web_request.py +++ b/aiohttp/web_request.py @@ -582,7 +582,7 @@ def cookies(self) -> Mapping[str, str]: A read-only dictionary-like object. """ raw = self.headers.get(hdrs.COOKIE, "") - parsed: SimpleCookie[str] = SimpleCookie(raw) + parsed = SimpleCookie(raw) return MappingProxyType({key: val.value for key, val in parsed.items()}) @reify diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py index aaf430a509d..e089c60ee4c 100644 --- a/aiohttp/web_response.py +++ b/aiohttp/web_response.py @@ -83,7 +83,7 @@ def __init__( self._chunked = False self._compression = False self._compression_force: Optional[ContentCoding] = None - self._cookies: SimpleCookie[str] = SimpleCookie() + self._cookies = SimpleCookie() self._req: Optional[BaseRequest] = None self._payload_writer: Optional[AbstractStreamWriter] = None @@ -193,7 +193,7 @@ def headers(self) -> "CIMultiDict[str]": return self._headers @property - def cookies(self) -> "SimpleCookie[str]": + def cookies(self) -> SimpleCookie: return self._cookies def set_cookie( diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 16a634c19e7..df021579ea0 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -108,7 +108,7 @@ multidict==6.0.4 # -r requirements/multidict.in # -r requirements/runtime-deps.in # yarl -mypy==1.6.1 ; implementation_name == "cpython" +mypy==1.7.0 ; implementation_name == "cpython" # via # -r requirements/lint.in # -r requirements/test.in diff --git a/requirements/dev.txt b/requirements/dev.txt index e296118e922..605327c4e94 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -103,7 +103,7 @@ multidict==6.0.4 # via # -r requirements/runtime-deps.in # yarl -mypy==1.6.1 ; implementation_name == "cpython" +mypy==1.7.0 ; implementation_name == "cpython" # via # -r requirements/lint.in # -r requirements/test.in diff --git a/requirements/lint.txt b/requirements/lint.txt index 3a1070a1644..e90f801862d 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -22,7 +22,7 @@ identify==2.5.26 # via pre-commit iniconfig==2.0.0 # via pytest -mypy==1.6.1 ; implementation_name == "cpython" +mypy==1.7.0 ; implementation_name == "cpython" # via -r requirements/lint.in mypy-extensions==1.0.0 # via mypy diff --git a/requirements/test.txt b/requirements/test.txt index 7a9e6f1c50a..0f8a7ef8ee1 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -53,7 +53,7 @@ multidict==6.0.4 # via # -r requirements/runtime-deps.in # yarl -mypy==1.6.1 ; implementation_name == "cpython" +mypy==1.7.0 ; implementation_name == "cpython" # via -r requirements/test.in mypy-extensions==1.0.0 # via mypy