From b0c81d8b15639a86bbe0a875594a9fb60efd4fc6 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 16 Jun 2025 17:13:42 +0000
Subject: [PATCH] Bump mypy from 1.15.0 to 1.16.0 (#11093)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Bumps [mypy](https://github.com/python/mypy) from 1.15.0 to 1.16.0.
Changelog
Sourced from mypy's
changelog.
Mypy Release Notes
Next Release
Mypy 1.16
We’ve just uploaded mypy 1.16 to the Python Package Index (PyPI).
Mypy is a static type checker for Python. This release includes new
features and bug fixes.
You can install it as follows:
python3 -m pip install -U mypy
You can read the full documentation for this release on Read the Docs.
Different Property Getter and Setter Types
Mypy now supports using different types for a property getter and
setter:
class A:
_value: int
@property
def foo(self) -> int:
return self._value
@foo.setter
def foo(self, x: str | int) -> None:
try:
self._value = int(x)
except ValueError:
raise Exception(f"'{x}' is not a valid value for
'foo'")
This was contributed by Ivan Levkivskyi (PR 18510).
Flexible Variable Redefinitions (Experimental)
Mypy now allows unannotated variables to be freely redefined with
different types when using the experimental
--allow-redefinition-new
flag. You will also need to enable --local-partial-types.
Mypy will
now infer a union type when different types are assigned to a
variable:
# mypy: allow-redefinition-new, local-partial-types
def f(n: int, b: bool) -> int | str:
if b:
x = n
else:
</tr></table>
... (truncated)
Commits
9e72e96
Update version to 1.16.0
8fe719f
Add changelog for 1.16 (#19138)
2a036e7
Revert "Infer correct types with overloads of Type[Guard |
Is] (#19161)
b6da4fc
Allow enum members to have type objects as values (#19160)
334469f
[mypyc] Improve documentation of native and non-native classes (#19154)
a499d9f
Document --allow-redefinition-new (#19153)
96525a2
Merge commit '9e45dadcf6d8dbab36f83d9df94a706c0b4f9207' into
release-1.16
9e45dad
Clear more data in TypeChecker.reset() instead of asserting (#19087)
772cd0c
Add --strict-bytes to --strict (#19049)
0b65f21
Admit that Final variables are never redefined (#19083)
- Additional commits viewable in compare
view
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
---------
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam Bull
---
aiohttp/abc.py | 2 +-
aiohttp/client.py | 4 ++--
aiohttp/client_reqrep.py | 2 +-
aiohttp/formdata.py | 2 +-
aiohttp/helpers.py | 10 +++++-----
aiohttp/http_writer.py | 4 ++--
aiohttp/pytest_plugin.py | 8 ++++----
aiohttp/test_utils.py | 6 +++---
aiohttp/web_app.py | 6 +++---
aiohttp/web_fileresponse.py | 8 ++++----
aiohttp/web_routedef.py | 4 ++--
aiohttp/web_runner.py | 2 +-
aiohttp/web_server.py | 4 ++--
aiohttp/worker.py | 2 +-
requirements/constraints.txt | 4 +++-
requirements/dev.txt | 4 +++-
requirements/lint.txt | 4 +++-
requirements/test.txt | 4 +++-
tests/test_client_request.py | 20 ++++++++++----------
tests/test_web_response.py | 18 +++++++++---------
20 files changed, 63 insertions(+), 55 deletions(-)
diff --git a/aiohttp/abc.py b/aiohttp/abc.py
index f8a8442a7b4..f29828285b0 100644
--- a/aiohttp/abc.py
+++ b/aiohttp/abc.py
@@ -82,7 +82,7 @@ def http_exception(self) -> Optional[HTTPException]:
"""HTTPException instance raised on router's resolving, or None"""
@abstractmethod # pragma: no branch
- def get_info(self) -> Dict[str, Any]: # type: ignore[misc]
+ def get_info(self) -> Dict[str, Any]:
"""Return a dict with additional info useful for introspection"""
@property # pragma: no branch
diff --git a/aiohttp/client.py b/aiohttp/client.py
index 284814a5792..29c63a6b031 100644
--- a/aiohttp/client.py
+++ b/aiohttp/client.py
@@ -1301,7 +1301,7 @@ def skip_auto_headers(self) -> FrozenSet[istr]:
return self._skip_auto_headers
@property
- def auth(self) -> Optional[BasicAuth]: # type: ignore[misc]
+ def auth(self) -> Optional[BasicAuth]:
"""An object that represents HTTP Basic Authorization"""
return self._default_auth
@@ -1338,7 +1338,7 @@ def trust_env(self) -> bool:
return self._trust_env
@property
- def trace_configs(self) -> List[TraceConfig[Any]]: # type: ignore[misc]
+ def trace_configs(self) -> List[TraceConfig[Any]]:
"""A list of TraceConfig instances used for client tracing"""
return self._trace_configs
diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py
index aa5b220fe48..ff5ec9432de 100644
--- a/aiohttp/client_reqrep.py
+++ b/aiohttp/client_reqrep.py
@@ -862,7 +862,7 @@ def ssl(self) -> Union["SSLContext", bool, Fingerprint]:
return self._ssl
@property
- def connection_key(self) -> ConnectionKey: # type: ignore[misc]
+ def connection_key(self) -> ConnectionKey:
if proxy_headers := self.proxy_headers:
h: Optional[int] = hash(tuple(proxy_headers.items()))
else:
diff --git a/aiohttp/formdata.py b/aiohttp/formdata.py
index 1b74cf8da02..27d395a2a04 100644
--- a/aiohttp/formdata.py
+++ b/aiohttp/formdata.py
@@ -89,7 +89,7 @@ def add_fields(self, *fields: Any) -> None:
elif isinstance(rec, (list, tuple)) and len(rec) == 2:
k, fp = rec
- self.add_field(k, fp) # type: ignore[arg-type]
+ self.add_field(k, fp)
else:
raise TypeError(
diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py
index 22a459586c7..97a04b6d6bd 100644
--- a/aiohttp/helpers.py
+++ b/aiohttp/helpers.py
@@ -145,7 +145,7 @@ def __new__(
return super().__new__(cls, login, password, encoding)
@classmethod
- def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth": # type: ignore[misc]
+ def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth":
"""Create a BasicAuth object from an Authorization HTTP header."""
try:
auth_type, encoded_credentials = auth_header.split(" ", 1)
@@ -174,7 +174,7 @@ def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth": # t
return cls(username, password, encoding=encoding)
@classmethod
- def from_url(cls, url: URL, *, encoding: str = "latin1") -> Optional["BasicAuth"]: # type: ignore[misc]
+ def from_url(cls, url: URL, *, encoding: str = "latin1") -> Optional["BasicAuth"]:
"""Create BasicAuth from url."""
if not isinstance(url, URL):
raise TypeError("url should be yarl.URL instance")
@@ -245,7 +245,7 @@ def netrc_from_env() -> Optional[netrc.netrc]:
@frozen_dataclass_decorator
-class ProxyInfo: # type: ignore[misc]
+class ProxyInfo:
proxy: URL
proxy_auth: Optional[BasicAuth]
@@ -884,7 +884,7 @@ def __init_subclass__(cls) -> None:
def __getitem__(self, key: AppKey[_T]) -> _T: ...
@overload
- def __getitem__(self, key: str) -> Any: ... # type: ignore[misc]
+ def __getitem__(self, key: str) -> Any: ...
def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
for mapping in self._maps:
@@ -901,7 +901,7 @@ def get(self, key: AppKey[_T], default: _S) -> Union[_T, _S]: ...
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...
@overload
- def get(self, key: str, default: Any = ...) -> Any: ... # type: ignore[misc]
+ def get(self, key: str, default: Any = ...) -> Any: ...
def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
try:
diff --git a/aiohttp/http_writer.py b/aiohttp/http_writer.py
index 1772e3c518b..c290d81db59 100644
--- a/aiohttp/http_writer.py
+++ b/aiohttp/http_writer.py
@@ -100,7 +100,7 @@ def _write(
transport = self._protocol.transport
if transport is None or transport.is_closing():
raise ClientConnectionResetError("Cannot write to closing transport")
- transport.write(chunk) # type: ignore[arg-type]
+ transport.write(chunk)
def _writelines(
self,
@@ -119,7 +119,7 @@ def _writelines(
if SKIP_WRITELINES or size < MIN_PAYLOAD_FOR_WRITELINES:
transport.write(b"".join(chunks))
else:
- transport.writelines(chunks) # type: ignore[arg-type]
+ transport.writelines(chunks)
def _write_chunked_payload(
self, chunk: Union[bytes, bytearray, "memoryview[int]", "memoryview[bytes]"]
diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py
index bce4cda68ce..d15876cba66 100644
--- a/aiohttp/pytest_plugin.py
+++ b/aiohttp/pytest_plugin.py
@@ -42,7 +42,7 @@
class AiohttpClient(Protocol):
# TODO(PY311): Use Unpack to specify ClientSession kwargs.
@overload
- async def __call__( # type: ignore[misc]
+ async def __call__(
self,
__param: Application,
*,
@@ -50,7 +50,7 @@ async def __call__( # type: ignore[misc]
**kwargs: Any,
) -> TestClient[Request, Application]: ...
@overload
- async def __call__( # type: ignore[misc]
+ async def __call__(
self,
__param: BaseTestServer[_Request],
*,
@@ -400,14 +400,14 @@ def aiohttp_client( # type: ignore[misc]
clients = []
@overload
- async def go( # type: ignore[misc]
+ async def go(
__param: Application,
*,
server_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> TestClient[Request, Application]: ...
@overload
- async def go( # type: ignore[misc]
+ async def go(
__param: BaseTestServer[_Request],
*,
server_kwargs: Optional[Dict[str, Any]] = None,
diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py
index 28b3e21df0a..5d1c885d8d5 100644
--- a/aiohttp/test_utils.py
+++ b/aiohttp/test_utils.py
@@ -155,7 +155,7 @@ async def start_server(self, **kwargs: Any) -> None:
self._root = URL(f"{self.scheme}://{absolute_host}:{self.port}")
@abstractmethod
- async def _make_runner(self, **kwargs: Any) -> BaseRunner[_Request]: # type: ignore[misc]
+ async def _make_runner(self, **kwargs: Any) -> BaseRunner[_Request]:
"""Return a new runner for the server."""
# TODO(PY311): Use Unpack to specify Server kwargs.
@@ -265,7 +265,7 @@ class TestClient(Generic[_Request, _ApplicationNone]):
__test__ = False
@overload
- def __init__( # type: ignore[misc]
+ def __init__(
self: "TestClient[Request, Application]",
server: TestServer,
*,
@@ -273,7 +273,7 @@ def __init__( # type: ignore[misc]
**kwargs: Any,
) -> None: ...
@overload
- def __init__( # type: ignore[misc]
+ def __init__(
self: "TestClient[_Request, None]",
server: BaseTestServer[_Request],
*,
diff --git a/aiohttp/web_app.py b/aiohttp/web_app.py
index 91c6ef009f4..78fb1da8514 100644
--- a/aiohttp/web_app.py
+++ b/aiohttp/web_app.py
@@ -164,7 +164,7 @@ def __eq__(self, other: object) -> bool:
def __getitem__(self, key: AppKey[_T]) -> _T: ...
@overload
- def __getitem__(self, key: str) -> Any: ... # type: ignore[misc]
+ def __getitem__(self, key: str) -> Any: ...
def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
return self._state[key]
@@ -179,7 +179,7 @@ def _check_frozen(self) -> None:
def __setitem__(self, key: AppKey[_T], value: _T) -> None: ...
@overload
- def __setitem__(self, key: str, value: Any) -> None: ... # type: ignore[misc]
+ def __setitem__(self, key: str, value: Any) -> None: ...
def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:
self._check_frozen()
@@ -213,7 +213,7 @@ def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...
def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]: ...
@overload
- def get(self, key: str, default: Any = ...) -> Any: ... # type: ignore[misc]
+ def get(self, key: str, default: Any = ...) -> Any: ...
def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
return self._state.get(key, default)
diff --git a/aiohttp/web_fileresponse.py b/aiohttp/web_fileresponse.py
index 28694d33dbd..6b7d002a86c 100644
--- a/aiohttp/web_fileresponse.py
+++ b/aiohttp/web_fileresponse.py
@@ -160,8 +160,8 @@ async def _not_modified(
) -> Optional[AbstractStreamWriter]:
self.set_status(HTTPNotModified.status_code)
self._length_check = False
- self.etag = etag_value # type: ignore[assignment]
- self.last_modified = last_modified # type: ignore[assignment]
+ self.etag = etag_value
+ self.last_modified = last_modified
# Delete any Content-Length headers provided by user. HTTP 304
# should always have empty response body
return await super().prepare(request)
@@ -391,8 +391,8 @@ async def _prepare_open_file(
# compress.
self._compression = False
- self.etag = f"{st.st_mtime_ns:x}-{st.st_size:x}" # type: ignore[assignment]
- self.last_modified = file_mtime # type: ignore[assignment]
+ self.etag = f"{st.st_mtime_ns:x}-{st.st_size:x}"
+ self.last_modified = file_mtime
self.content_length = count
self._headers[hdrs.ACCEPT_RANGES] = "bytes"
diff --git a/aiohttp/web_routedef.py b/aiohttp/web_routedef.py
index 51c28a074a2..3d644a0d404 100644
--- a/aiohttp/web_routedef.py
+++ b/aiohttp/web_routedef.py
@@ -54,7 +54,7 @@ def register(self, router: UrlDispatcher) -> List[AbstractRoute]:
@dataclasses.dataclass(frozen=True, repr=False)
-class RouteDef(AbstractRouteDef): # type: ignore[misc]
+class RouteDef(AbstractRouteDef):
method: str
path: str
handler: _HandlerType
@@ -79,7 +79,7 @@ def register(self, router: UrlDispatcher) -> List[AbstractRoute]:
@dataclasses.dataclass(frozen=True, repr=False)
-class StaticDef(AbstractRouteDef): # type: ignore[misc]
+class StaticDef(AbstractRouteDef):
prefix: str
path: PathLike
kwargs: Dict[str, Any]
diff --git a/aiohttp/web_runner.py b/aiohttp/web_runner.py
index 11f692ce07e..c5e62003a34 100644
--- a/aiohttp/web_runner.py
+++ b/aiohttp/web_runner.py
@@ -254,7 +254,7 @@ def server(self) -> Optional[Server[_Request]]:
return self._server
@property
- def addresses(self) -> List[Any]: # type: ignore[misc]
+ def addresses(self) -> List[Any]:
ret: List[Any] = []
for site in self._sites:
server = site._server
diff --git a/aiohttp/web_server.py b/aiohttp/web_server.py
index 4a82c5ef77c..53827a62590 100644
--- a/aiohttp/web_server.py
+++ b/aiohttp/web_server.py
@@ -40,7 +40,7 @@ class Server(Generic[_Request]):
request_factory: _RequestFactory[_Request]
@overload
- def __init__( # type: ignore[misc]
+ def __init__(
self: "Server[BaseRequest]",
handler: Callable[[_Request], Awaitable[StreamResponse]],
*,
@@ -49,7 +49,7 @@ def __init__( # type: ignore[misc]
**kwargs: Any, # TODO(PY311): Use Unpack to define kwargs from RequestHandler
) -> None: ...
@overload
- def __init__( # type: ignore[misc]
+ def __init__(
self,
handler: Callable[[_Request], Awaitable[StreamResponse]],
*,
diff --git a/aiohttp/worker.py b/aiohttp/worker.py
index d4f062062a5..ed6abd43eb6 100644
--- a/aiohttp/worker.py
+++ b/aiohttp/worker.py
@@ -203,7 +203,7 @@ def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:
sys.exit(1)
@staticmethod
- def _create_ssl_context(cfg: Any) -> "SSLContext": # type: ignore[misc]
+ def _create_ssl_context(cfg: Any) -> "SSLContext":
"""Creates SSLContext instance for usage in asyncio.create_server.
See ssl.SSLSocket.__init__ for more details.
diff --git a/requirements/constraints.txt b/requirements/constraints.txt
index c3b4b8d4e39..7e6452dcacf 100644
--- a/requirements/constraints.txt
+++ b/requirements/constraints.txt
@@ -118,7 +118,7 @@ multidict==6.4.4
# -r requirements/multidict.in
# -r requirements/runtime-deps.in
# yarl
-mypy==1.15.0 ; implementation_name == "cpython"
+mypy==1.16.1 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test.in
@@ -133,6 +133,8 @@ packaging==25.0
# pytest
# sphinx
# wheel
+pathspec==0.12.1
+ # via mypy
pip-tools==7.4.1
# via -r requirements/dev.in
pkgconfig==1.5.5
diff --git a/requirements/dev.txt b/requirements/dev.txt
index 0ef6ddf86b0..cd14dff2ba1 100644
--- a/requirements/dev.txt
+++ b/requirements/dev.txt
@@ -115,7 +115,7 @@ multidict==6.4.4
# via
# -r requirements/runtime-deps.in
# yarl
-mypy==1.15.0 ; implementation_name == "cpython"
+mypy==1.16.1 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test.in
@@ -130,6 +130,8 @@ packaging==25.0
# pytest
# sphinx
# wheel
+pathspec==0.12.1
+ # via mypy
pip-tools==7.4.1
# via -r requirements/dev.in
pkgconfig==1.5.5
diff --git a/requirements/lint.txt b/requirements/lint.txt
index 8e031469549..722fc171ebc 100644
--- a/requirements/lint.txt
+++ b/requirements/lint.txt
@@ -45,7 +45,7 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
-mypy==1.15.0 ; implementation_name == "cpython"
+mypy==1.16.1 ; implementation_name == "cpython"
# via -r requirements/lint.in
mypy-extensions==1.1.0
# via mypy
@@ -53,6 +53,8 @@ nodeenv==1.9.1
# via pre-commit
packaging==25.0
# via pytest
+pathspec==0.12.1
+ # via mypy
platformdirs==4.3.8
# via virtualenv
pluggy==1.6.0
diff --git a/requirements/test.txt b/requirements/test.txt
index 6861e46370f..94997d80f34 100644
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -61,7 +61,7 @@ multidict==6.4.4
# via
# -r requirements/runtime-deps.in
# yarl
-mypy==1.15.0 ; implementation_name == "cpython"
+mypy==1.16.1 ; implementation_name == "cpython"
# via -r requirements/test.in
mypy-extensions==1.1.0
# via mypy
@@ -69,6 +69,8 @@ packaging==25.0
# via
# gunicorn
# pytest
+pathspec==0.12.1
+ # via mypy
pkgconfig==1.5.5
# via -r requirements/test.in
pluggy==1.6.0
diff --git a/tests/test_client_request.py b/tests/test_client_request.py
index f51aea2e8e9..23b27556ab1 100644
--- a/tests/test_client_request.py
+++ b/tests/test_client_request.py
@@ -1374,7 +1374,7 @@ async def test_oserror_on_write_bytes(
loop: asyncio.AbstractEventLoop, conn: mock.Mock
) -> None:
req = ClientRequest("POST", URL("http://python.org/"), loop=loop)
- req.body = b"test data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = b"test data"
writer = WriterMock()
writer.write.side_effect = OSError
@@ -1722,7 +1722,7 @@ async def test_write_bytes_with_content_length_limit(
data = b"Hello World"
req = ClientRequest("post", URL("http://python.org/"), loop=loop)
- req.body = data # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = data
writer = StreamWriter(protocol=conn.protocol, loop=loop)
# Use content_length=5 to truncate data
@@ -1757,9 +1757,9 @@ async def gen() -> AsyncIterator[bytes]:
for chunk in data:
yield chunk
- req.body = gen() # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = gen()
else:
- req.body = data # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = data
writer = StreamWriter(protocol=conn.protocol, loop=loop)
# Use content_length=7 to truncate at the middle of Part2
@@ -1780,7 +1780,7 @@ async def gen() -> AsyncIterator[bytes]:
return
yield # pragma: no cover # This makes it a generator but never executes
- req.body = gen() # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = gen()
writer = StreamWriter(protocol=conn.protocol, loop=loop)
# Use content_length=10 with empty body
@@ -1809,7 +1809,7 @@ async def test_warn_if_unclosed_payload_via_body_setter(
ResourceWarning,
match="The previous request body contains unclosed resources",
):
- req.body = b"new data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = b"new data"
await req.close()
@@ -1827,7 +1827,7 @@ async def test_no_warn_for_autoclose_payload_via_body_setter(
# Setting body again should not trigger warning since previous payload has autoclose=True
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always")
- req.body = b"new data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = b"new data"
# Filter out any non-ResourceWarning warnings
resource_warnings = [
@@ -1857,7 +1857,7 @@ async def test_no_warn_for_consumed_payload_via_body_setter(
# Setting body again should not trigger warning since previous payload is consumed
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always")
- req.body = b"new data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = b"new data"
# Filter out any non-ResourceWarning warnings
resource_warnings = [
@@ -1976,7 +1976,7 @@ async def test_body_setter_closes_previous_payload(
req._body = mock_payload
# Update body with new data using setter
- req.body = b"new body data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
+ req.body = b"new body data"
# Verify the previous payload was closed using _close
mock_payload._close.assert_called_once()
@@ -2105,7 +2105,7 @@ async def test_warn_stacklevel_points_to_user_code(
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always", ResourceWarning)
# This line should be reported as the warning source
- req.body = b"new data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892 # LINE TO BE REPORTED
+ req.body = b"new data"
# Find the ResourceWarning
resource_warnings = [
diff --git a/tests/test_web_response.py b/tests/test_web_response.py
index 13425026f1e..04008a7c579 100644
--- a/tests/test_web_response.py
+++ b/tests/test_web_response.py
@@ -210,7 +210,7 @@ def test_last_modified_string() -> None:
resp = web.StreamResponse()
dt = datetime.datetime(1990, 1, 2, 3, 4, 5, 0, datetime.timezone.utc)
- resp.last_modified = "Mon, 2 Jan 1990 03:04:05 GMT" # type: ignore[assignment]
+ resp.last_modified = "Mon, 2 Jan 1990 03:04:05 GMT"
assert resp.last_modified == dt
@@ -219,10 +219,10 @@ def test_last_modified_timestamp() -> None:
dt = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, datetime.timezone.utc)
- resp.last_modified = 0 # type: ignore[assignment]
+ resp.last_modified = 0
assert resp.last_modified == dt
- resp.last_modified = 0.0 # type: ignore[assignment]
+ resp.last_modified = 0.0
assert resp.last_modified == dt
@@ -237,7 +237,7 @@ def test_last_modified_datetime() -> None:
def test_last_modified_reset() -> None:
resp = web.StreamResponse()
- resp.last_modified = 0 # type: ignore[assignment]
+ resp.last_modified = 0
resp.last_modified = None
assert resp.last_modified is None
@@ -270,7 +270,7 @@ def test_etag_initial() -> None:
def test_etag_string() -> None:
resp = web.StreamResponse()
value = "0123-kotik"
- resp.etag = value # type: ignore[assignment]
+ resp.etag = value
assert resp.etag == ETag(value=value)
assert resp.headers[hdrs.ETAG] == f'"{value}"'
@@ -291,7 +291,7 @@ def test_etag_class(etag: ETag, expected_header: str) -> None:
def test_etag_any() -> None:
resp = web.StreamResponse()
- resp.etag = "*" # type: ignore[assignment]
+ resp.etag = "*"
assert resp.etag == ETag(value="*")
assert resp.headers[hdrs.ETAG] == "*"
@@ -308,7 +308,7 @@ def test_etag_any() -> None:
def test_etag_invalid_value_set(invalid_value: Union[str, ETag]) -> None:
resp = web.StreamResponse()
with pytest.raises(ValueError, match="is not a valid etag"):
- resp.etag = invalid_value # type: ignore[assignment]
+ resp.etag = invalid_value
@pytest.mark.parametrize(
@@ -333,7 +333,7 @@ def test_etag_invalid_value_class(invalid: Union[int, ETag]) -> None:
def test_etag_reset() -> None:
resp = web.StreamResponse()
- resp.etag = "*" # type: ignore[assignment]
+ resp.etag = "*"
resp.etag = None
assert resp.etag is None
@@ -1062,7 +1062,7 @@ async def test_assign_nonbyteish_body() -> None:
resp = web.Response(body=b"data")
with pytest.raises(ValueError):
- resp.body = 123 # type: ignore[assignment]
+ resp.body = 123
assert b"data" == resp.body
assert 4 == resp.content_length