Skip to content

Commit

Permalink
Add inject_self.property
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Nov 11, 2023
1 parent 71aa3c9 commit 288c61d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stgpytools/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ def clean(cls, function: Callable[Concatenate[T0, P0], R0]) -> inject_self[T0, P
inj.clean_kwargs = True
return inj # type: ignore

class property(Generic[T0, R0]):
def __init__(self, function: Callable[[T0], R0]) -> None:
self.function = inject_self(function)

def __get__(
self, class_obj: type[T0] | T0 | None, class_type: type[T0] | type[type[T0]] # type: ignore
) -> R0:
return self.function.__get__(class_obj, class_type)()


class complex_hash(Generic[T]):
"""
Expand Down

0 comments on commit 288c61d

Please sign in to comment.