diff --git a/scrapy/_classutilities.py b/scrapy/_classutilities.py index ee58ea62f..3545ba7d0 100644 --- a/scrapy/_classutilities.py +++ b/scrapy/_classutilities.py @@ -3,7 +3,7 @@ # https://github.com/david-salac/classutilities/blob/a6e4a86331936d432afaa454ed4c963528165a61/src/classutilities/classproperty.py # Allows creating a class level property -from typing import Any, Callable +from typing import Any, Callable, Optional, Union class ClassPropertyContainer: @@ -21,7 +21,7 @@ class ClassPropertyContainer: self.prop_get: Any = prop_get self.prop_set: Any = prop_set - def __get__(self, obj: Any, cls: type = None) -> Callable: + def __get__(self, obj: Any, cls: Optional[type] = None) -> Callable: """ Get the property getter. :param obj: Instance of the class. @@ -46,7 +46,9 @@ class ClassPropertyContainer: _type = obj return self.prop_set.__get__(obj, _type)(value) - def setter(self, func: Callable) -> "ClassPropertyContainer": + def setter( + self, func: Union[Callable, classmethod, staticmethod] + ) -> "ClassPropertyContainer": """ Allows creating setter in a property like way. :param func: Getter function. diff --git a/scrapy/core/scraper.py b/scrapy/core/scraper.py index 02ab8d3e4..a5d392870 100644 --- a/scrapy/core/scraper.py +++ b/scrapy/core/scraper.py @@ -85,7 +85,7 @@ class Slot(ClassPropertiesMixin): ) return cls._MIN_RESPONSE_SIZE - @MIN_RESPONSE_SIZE.setter + @MIN_RESPONSE_SIZE.setter # type: ignore[no-redef] def MIN_RESPONSE_SIZE(cls, value): warn( "scrapy.core.scraper.Slot.MIN_RESPONSE_SIZE is deprecated.", @@ -93,7 +93,7 @@ class Slot(ClassPropertiesMixin): ) cls._MIN_RESPONSE_SIZE = value - def __init__(self, max_active_size: int = _UNSET): + def __init__(self, max_active_size: Any = _UNSET): if max_active_size is not _UNSET: warn( (