Solve linting and typing issues

This commit is contained in:
Adrián Chaves 2023-11-23 12:07:15 +01:00
parent b53ed52a22
commit cf80e5670e
2 changed files with 4 additions and 2 deletions

View File

@ -93,7 +93,7 @@ class HttpCompressionMiddleware:
f"({len(response.body)} B) exceeded DOWNLOAD_MAXSIZE "
f"({self._max_size} B) during decompression."
)
if len(response.body) < warn_size and len(decoded_body) >= warn_size:
if len(response.body) < warn_size <= len(decoded_body):
logger.warning(
f"{response} body size after decompression "
f"({len(decoded_body)} B) is larger than the "

View File

@ -22,6 +22,8 @@ class SitemapSpider(Spider):
sitemap_rules = [("", "parse")]
sitemap_follow = [""]
sitemap_alternate_links = False
_max_size: int
_warn_size: int
@classmethod
def from_crawler(cls, crawler: "Crawler", *args: Any, **kwargs: Any) -> "Self":
@ -97,7 +99,7 @@ class SitemapSpider(Spider):
body = gunzip(response.body, max_size=max_size)
except _DecompressionMaxSizeExceeded:
return None
if uncompressed_size < warn_size and len(body) >= warn_size:
if uncompressed_size < warn_size <= len(body):
logger.warning(
f"{response} body size after decompression ({len(body)} B) "
f"is larger than the download warning size ({warn_size} B)."