mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
2987d93ba7
commit_hash:cf5070a543788fa57136adb1a4a7ea42f4490329
19 lines
444 B
Python
19 lines
444 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",)
|