From 3aab42074fa81acbcdbd042a98c66e4025a4d665 Mon Sep 17 00:00:00 2001 From: Setsugennoao <41454651+Setsugennoao@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:45:43 +0100 Subject: [PATCH] Typing fixes --- stgpytools/types/utils.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/stgpytools/types/utils.py b/stgpytools/types/utils.py index f542dd4..a8d6337 100644 --- a/stgpytools/types/utils.py +++ b/stgpytools/types/utils.py @@ -97,7 +97,7 @@ def __call__(*args: Any, **kwds: Any) -> Any: ... -self_objects_cache = dict[type[T], T]() +self_objects_cache = dict[type[T], T]() # type: ignore class inject_self_base(Generic[T, P, R]): @@ -424,36 +424,36 @@ def __setattr__(self, key: str, value: Any) -> None: def __init__( self, - fget: classmethod[R] | Callable[P, R], - fset: classmethod[None] | Callable[[T, T0], None] | None = None, - fdel: classmethod[None] | Callable[P0, None] | None = None, + fget: classmethod[T, P, R] | Callable[P, R], + fset: classmethod[T, P, None] | Callable[[T, T0], None] | None = None, + fdel: classmethod[T, P1, None] | Callable[P1, None] | None = None, doc: str | None = None, ) -> None: if not isinstance(fget, (classmethod, staticmethod)): - fget = classmethod(fget) + fget = classmethod(fget) # type: ignore self.fget = self._wrap(fget) - self.fset = self._wrap(fset) if fset is not None else fset + self.fset = self._wrap(fset) if fset is not None else fset # type: ignore self.fdel = self._wrap(fdel) if fdel is not None else fdel self.doc = doc - def _wrap(self, func: classmethod[R1] | Callable[P1, R1]) -> classmethod[R1]: + def _wrap(self, func: classmethod[T1, P1, R1] | Callable[P1, R1]) -> classmethod[T1, P1, R1]: if not isinstance(func, (classmethod, staticmethod)): - func = classmethod(func) + func = classmethod(func) # type: ignore return func - def getter(self, __fget: classmethod[R] | Callable[P1, R1]) -> classproperty[P1, R1, T, T0, P0]: + def getter(self, __fget: classmethod[T, P, R] | Callable[P1, R1]) -> classproperty[P1, R1, T, T0, P0]: self.fget = self._wrap(__fget) # type: ignore return self # type: ignore - def setter(self, __fset: classmethod[None] | Callable[[T1, T2], None]) -> classproperty[P, R, T1, T2, P0]: - self.fset = self._wrap(__fset) + def setter(self, __fset: classmethod[T1, P, None] | Callable[[T1, T2], None]) -> classproperty[P, R, T1, T2, P0]: + self.fset = self._wrap(__fset) # type: ignore return self # type: ignore - def deleter(self, __fdel: classmethod[None] | Callable[P1, None]) -> classproperty[P, R, T, T0, P1]: - self.fdel = self._wrap(__fdel) + def deleter(self, __fdel: classmethod[T1, P1, None] | Callable[P1, None]) -> classproperty[P, R, T, T0, P1]: + self.fdel = self._wrap(__fdel) # type: ignore return self # type: ignore def __get__(self, __obj: Any, __type: type | None = None) -> R: @@ -473,7 +473,7 @@ def __set__(self, __obj: Any, __value: T1) -> None: else: type_ = type(__obj) - return self.fset.__get__(__obj, type_)(__value) + return self.fset.__get__(__obj, type_)(__value) # type: ignore def __delete__(self, __obj: Any) -> None: from ..exceptions import CustomError @@ -559,7 +559,7 @@ def __new__(cls, *args: Any, **kwargs: Any) -> KwargsNotNone: class SingletonMeta(type): - _instances = dict[type[SingleMeta], SingleMeta]() + _instances = dict[type[SingleMeta], SingleMeta]() # type: ignore _singleton_init: bool def __new__(