diff --git a/scrapy/pipelines/media.py b/scrapy/pipelines/media.py index ea36a9e8a..6bd3ed9b4 100644 --- a/scrapy/pipelines/media.py +++ b/scrapy/pipelines/media.py @@ -211,7 +211,7 @@ class MediaPipeline(ABC): # minimize cached information for failure result.cleanFailure() result.frames = [] - result.stack = None + result.stack = [] # This code fixes a memory leak by avoiding to keep references to # the Request and Response objects on the Media Pipeline cache. diff --git a/scrapy/utils/defer.py b/scrapy/utils/defer.py index c5763a06c..33ec23cec 100644 --- a/scrapy/utils/defer.py +++ b/scrapy/utils/defer.py @@ -19,6 +19,7 @@ from typing import ( Callable, Coroutine, Dict, + Generic, Iterable, Iterator, List, @@ -144,7 +145,7 @@ def parallel( return DeferredList([coop.coiterate(work) for _ in range(count)]) -class _AsyncCooperatorAdapter(Iterator[Deferred]): +class _AsyncCooperatorAdapter(Iterator[Deferred], Generic[_T]): """A class that wraps an async iterable into a normal iterator suitable for using in Cooperator.coiterate(). As it's only needed for parallel_async(), it calls the callable directly in the callback, instead of providing a more diff --git a/scrapy/utils/log.py b/scrapy/utils/log.py index 439b065a9..4a70de6b4 100644 --- a/scrapy/utils/log.py +++ b/scrapy/utils/log.py @@ -128,7 +128,7 @@ def configure_logging( settings = Settings(settings) if settings.getbool("LOG_STDOUT"): - sys.stdout = StreamLogger(logging.getLogger("stdout")) # type: ignore[assignment] + sys.stdout = StreamLogger(logging.getLogger("stdout")) if install_root_handler: install_scrapy_root_handler(settings) diff --git a/scrapy/utils/ssl.py b/scrapy/utils/ssl.py index 95611ebd9..2c3a259c1 100644 --- a/scrapy/utils/ssl.py +++ b/scrapy/utils/ssl.py @@ -20,7 +20,7 @@ def x509name_to_string(x509name: X509Name) -> str: # from OpenSSL.crypto.X509Name.__repr__ result_buffer: Any = pyOpenSSLutil.ffi.new("char[]", 512) pyOpenSSLutil.lib.X509_NAME_oneline( - x509name._name, result_buffer, len(result_buffer) # type: ignore[attr-defined] + x509name._name, result_buffer, len(result_buffer) ) return ffi_buf_to_string(result_buffer) diff --git a/tox.ini b/tox.ini index e3dd96425..2d62f1cb7 100644 --- a/tox.ini +++ b/tox.ini @@ -46,16 +46,16 @@ install_command = [testenv:typing] basepython = python3 deps = - mypy==1.10.1 + mypy==1.11.1 typing-extensions==4.12.2 - types-lxml==2024.4.14 + types-lxml==2024.8.7 types-Pygments==2.18.0.20240506 - types-pyOpenSSL==24.1.0.20240425 - types-setuptools==70.3.0.20240710 - botocore-stubs==1.34.143 - boto3-stubs[s3]==1.34.143 + types-setuptools==71.1.0.20240806 + botocore-stubs==1.34.158 + boto3-stubs[s3]==1.34.158 attrs >= 18.2.0 Pillow >= 10.3.0 + pyOpenSSL >= 24.2.1 pytest >= 8.2.0 w3lib >= 2.2.0 commands =