79582246

Date: 2025-04-19 09:59:37
Score: 1
Natty:
Report link

For thoses who need type hint, this code works with pyright


class staticproperty(Generic[GetterReturnType]):

    def __init__(self, func: Callable[..., GetterReturnType]):
        if isinstance(func, staticmethod):
            fget = func
        else:
            fget = staticmethod(func)
        self.fget = fget

    def __get__(self, obj, klass=None) -> GetterReturnType:
        if klass is None:
            klass = type(obj)
        return self.fget.__get__(obj, klass)()

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: lei zhang