Address typing issues

This commit is contained in:
Adrián Chaves 2024-07-08 10:25:11 +02:00
parent 4b0c23194f
commit c22b450d0c
2 changed files with 7 additions and 5 deletions

View File

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

View File

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