mirror of https://github.com/scrapy/scrapy.git
Fix compatibility with Python 3.8.
This commit is contained in:
parent
048812ba35
commit
0ec79e3166
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import inspect
|
||||
import warnings
|
||||
from typing import Any, List, Optional, Tuple, Type, overload
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, overload
|
||||
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ def attribute(obj: Any, oldattr: str, newattr: str, version: str = "0.12") -> No
|
|||
def create_deprecated_class(
|
||||
name: str,
|
||||
new_class: type,
|
||||
clsdict: Optional[dict[str, Any]] = None,
|
||||
clsdict: Optional[Dict[str, Any]] = None,
|
||||
warn_category: Type[Warning] = ScrapyDeprecationWarning,
|
||||
warn_once: bool = True,
|
||||
old_class_path: Optional[str] = None,
|
||||
|
|
@ -59,14 +59,14 @@ def create_deprecated_class(
|
|||
warned_on_subclass: bool = False
|
||||
|
||||
def __new__(
|
||||
metacls, name: str, bases: Tuple[type, ...], clsdict_: dict[str, Any]
|
||||
metacls, name: str, bases: Tuple[type, ...], clsdict_: Dict[str, Any]
|
||||
) -> type:
|
||||
cls = super().__new__(metacls, name, bases, clsdict_)
|
||||
if metacls.deprecated_class is None:
|
||||
metacls.deprecated_class = cls
|
||||
return cls
|
||||
|
||||
def __init__(cls, name: str, bases: Tuple[type, ...], clsdict_: dict[str, Any]):
|
||||
def __init__(cls, name: str, bases: Tuple[type, ...], clsdict_: Dict[str, Any]):
|
||||
meta = cls.__class__
|
||||
old = meta.deprecated_class
|
||||
if old in bases and not (warn_once and meta.warned_on_subclass):
|
||||
|
|
|
|||
Loading…
Reference in New Issue