Fix compatibility with Python 3.8.

This commit is contained in:
Andrey Rakhmatullin 2023-05-07 23:01:27 +04:00
parent 048812ba35
commit 0ec79e3166
1 changed files with 4 additions and 4 deletions

View File

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