reflex/reflex/constants/utils.py
Khaleel Al-Adhami f39e8c9667
move all environment variables to the same place (#4192)
* move all environment variables to the same place

* reorder things around

* move more variables to environment

* remove cyclical imports

* forgot default value for field

* for some reason type hints aren't being interpreted

* put the field type *before* not after

* make it get

* move a bit more

* add more fields

* move reflex dir

* add return

* put things somewhere else

* add custom error
2024-10-21 13:28:55 -07:00

33 lines
789 B
Python

"""Utility functions for constants."""
from typing import Any, Callable, Generic, Type
from typing_extensions import 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)