Files
divkit/json-builder/python/pydivkit/core/compat.py
T
mosquito 573f9d62b8 Autoreformat code while building
autoreformat while build
2022-10-27 15:57:10 +03:00

20 lines
445 B
Python

from typing import Any, Callable, Generic, Type, TypeVar
T = TypeVar("T")
V = TypeVar("V")
# noinspection PyPep8Naming
class classproperty(Generic[T, V]):
""" mypy friendly classproperty """
def __init__(self, getter: Callable[[Type[T]], V]) -> None:
self.getter = getattr(getter, "__func__", getter)
def __get__(self, instance: Any, owner: Type[T]) -> V:
return self.getter(owner)
__all__ = "classproperty",