Scrapy, a fast high-level web crawling & scraping framework for Python.
Fix typing-related issued on Python < 3.9.
Andrey Rakhmatullin6998e1c905ef
diff --git a/scrapy/utils/datatypes.py b/scrapy/utils/datatypes.pyindex 599b201ea..0f6bdc5ab 100644--- a/scrapy/utils/datatypes.py+++ b/scrapy/utils/datatypes.py@@ -5,10 +5,9 @@ Python Standard Library.This module must not depend on any module outside the Standard Library."""-import collectionsimport weakreffrom collections.abc import Mapping-from typing import Any, Optional, Sequence, TypeVar+from typing import Any, Optional, OrderedDict, Sequence, TypeVar_KT = TypeVar("_KT")_VT = TypeVar("_VT")@@ -68,7 +67,7 @@ class CaselessDict(dict):return dict.pop(self, self.normkey(key), *args)-class LocalCache(collections.OrderedDict[_KT, _VT]):+class LocalCache(OrderedDict[_KT, _VT]):"""Dictionary with a finite number of keys.Older items expires first.@@ -85,7 +84,7 @@ class LocalCache(collections.OrderedDict[_KT, _VT]):super().__setitem__(key, value)-class LocalWeakReferencedCache(weakref.WeakKeyDictionary[_KT, _VT]):+class LocalWeakReferencedCache(weakref.WeakKeyDictionary):"""A weakref.WeakKeyDictionary implementation that uses LocalCache as itsunderlying data structure, making it ordered and capable of being size-limited.diff --git a/scrapy/utils/misc.py b/scrapy/utils/misc.pyindex defc8663d..70187ba74 100644--- a/scrapy/utils/misc.py+++ b/scrapy/utils/misc.py@@ -232,9 +232,7 @@ def walk_callable(node: ast.AST) -> Generator[ast.AST, Any, None]:yield node-_generator_callbacks_cache: LocalWeakReferencedCache[- Callable, bool-] = LocalWeakReferencedCache(limit=128)+_generator_callbacks_cache = LocalWeakReferencedCache(limit=128)def is_generator_with_return_value(callable: Callable) -> bool: