use the power of dataclasses

This commit is contained in:
Khaleel Al-Adhami 2024-10-29 10:50:16 -07:00
parent 6655b789e3
commit 2a85d8ce2a

View File

@ -303,6 +303,7 @@ def interpret_env_var_value(
) )
@dataclasses.dataclass(init=False)
class ExistingPath(Path): class ExistingPath(Path):
"""A path that must exist.""" """A path that must exist."""
@ -336,7 +337,9 @@ class EnvironmentVariables:
REFLEX_WEB_WORKDIR: Path = Path(constants.Dirs.WEB) REFLEX_WEB_WORKDIR: Path = Path(constants.Dirs.WEB)
# Path to the alembic config file # Path to the alembic config file
ALEMBIC_CONFIG: ExistingPath = ExistingPath(constants.ALEMBIC_CONFIG) ALEMBIC_CONFIG: ExistingPath = dataclasses.field(
default_factory=lambda: ExistingPath(constants.ALEMBIC_CONFIG)
)
# Disable SSL verification for HTTPX requests. # Disable SSL verification for HTTPX requests.
SSL_NO_VERIFY: bool = False SSL_NO_VERIFY: bool = False
@ -449,7 +452,7 @@ class Config(Base):
telemetry_enabled: bool = True telemetry_enabled: bool = True
# The bun path # The bun path
bun_path: Path = constants.Bun.DEFAULT_PATH bun_path: ExistingPath = ExistingPath(constants.Bun.DEFAULT_PATH)
# List of origins that are allowed to connect to the backend API. # List of origins that are allowed to connect to the backend API.
cors_allowed_origins: List[str] = ["*"] cors_allowed_origins: List[str] = ["*"]