Typing fixes and updates. (#6460)

This commit is contained in:
Andrey Rakhmatullin 2024-08-23 15:48:01 +05:00 committed by GitHub
parent af15bd1dad
commit 5794071f96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 10 deletions

View File

@ -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.

View File

@ -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

View File

@ -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)

View File

@ -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)

12
tox.ini
View File

@ -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 =