Skip to content

Commit

Permalink
Typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Nov 18, 2023
1 parent daff9dd commit 3aab420
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions stgpytools/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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__(
Expand Down

0 comments on commit 3aab420

Please sign in to comment.