diff --git a/aiohttp/web_fileresponse.py b/aiohttp/web_fileresponse.py index d11a72e838a..1924f3fbfa3 100644 --- a/aiohttp/web_fileresponse.py +++ b/aiohttp/web_fileresponse.py @@ -109,16 +109,15 @@ async def _sendfile( def _strong_etag_match(etag_value: str, etags: Tuple[ETag, ...]) -> bool: if len(etags) == 1 and etags[0].value == ETAG_ANY: return True - else: - return any(etag.value == etag_value for etag in etags if not etag.is_weak) + return any(etag.value == etag_value for etag in etags if not etag.is_weak) async def _not_modified( self, request: "BaseRequest", etag_value: str, last_modified: float ) -> Optional[AbstractStreamWriter]: self.set_status(HTTPNotModified.status_code) self._length_check = False - self.etag = etag_value # type: ignore - self.last_modified = last_modified # type: ignore + self.etag = etag_value # type: ignore[assignment] + self.last_modified = last_modified # type: ignore[assignment] # Delete any Content-Length headers provided by user. HTTP 304 # should always have empty response body return await super().prepare(request) diff --git a/tests/test_web_request.py b/tests/test_web_request.py index 2ea671d0dac..eeeba2b44db 100644 --- a/tests/test_web_request.py +++ b/tests/test_web_request.py @@ -826,14 +826,14 @@ async def invalid_handler_1(request): @pytest.mark.parametrize( - "header,header_attr", + ["header", "header_attr"], [ pytest.param("If-Match", "if_match"), pytest.param("If-None-Match", "if_none_match"), ], ) @pytest.mark.parametrize( - "header_val,expected", + ["header_val", "expected"], [ pytest.param( '"67ab43", W/"54ed21", "7892,dd"', diff --git a/tests/test_web_response.py b/tests/test_web_response.py index 655bc2be59a..8aebd4e9d13 100644 --- a/tests/test_web_response.py +++ b/tests/test_web_response.py @@ -303,7 +303,7 @@ def test_etag_any() -> None: ) def test_etag_invalid_value_set(invalid_value) -> None: resp = StreamResponse() - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="is not a valid etag"): resp.etag = invalid_value