mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
573f9d62b8
autoreformat while build
20 lines
445 B
Python
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",
|