reflex/reflex/constants/utils.py
Khaleel Al-Adhami 946b7bc25a
upgrade deps as per python 3.10 (#4842)
* upgrade deps as per python 3.10

* no need for that guy
2025-02-18 13:56:58 -08:00

31 lines
759 B
Python

"""Utility functions for constants."""
from typing import Any, Callable, Generic, Type, TypeVar
T = TypeVar("T")
V = TypeVar("V")
class classproperty(Generic[T, V]):
"""A class property decorator."""
def __init__(self, getter: Callable[[Type[T]], V]) -> None:
"""Initialize the class property.
Args:
getter: The getter function.
"""
self.getter = getattr(getter, "__func__", getter)
def __get__(self, instance: Any, owner: Type[T]) -> V:
"""Get the value of the class property.
Args:
instance: The instance of the class.
owner: The class itself.
Returns:
The value of the class property.
"""
return self.getter(owner)