Skip to content

Types

provide.foundation.config.types

Type definitions for the configuration system.

Classes

ConfigFormat

Bases: Enum

Supported configuration file formats.

Functions
from_extension classmethod
from_extension(filename: str) -> ConfigFormat | None

Determine format from file extension.

Source code in provide/foundation/config/types.py
@classmethod
def from_extension(cls, filename: str) -> ConfigFormat | None:
    """Determine format from file extension."""
    ext_map = {
        ".json": cls.JSON,
        ".yaml": cls.YAML,
        ".yml": cls.YAML,
        ".toml": cls.TOML,
        ".ini": cls.INI,
        ".env": cls.ENV,
    }

    for ext, format_type in ext_map.items():
        if filename.lower().endswith(ext):
            return format_type
    return None

ConfigSource

Bases: Enum

Sources for configuration values with precedence order.

Functions
__eq__
__eq__(other: object) -> bool

Enable == comparison for precedence.

Source code in provide/foundation/config/types.py
def __eq__(self, other: object) -> bool:
    """Enable == comparison for precedence."""
    if not isinstance(other, ConfigSource):
        return NotImplemented
    return self.value == other.value
__ge__
__ge__(other: object) -> bool

Enable >= comparison for precedence.

Source code in provide/foundation/config/types.py
def __ge__(self, other: object) -> bool:
    """Enable >= comparison for precedence."""
    if not isinstance(other, ConfigSource):
        return NotImplemented
    return self.value >= other.value
__gt__
__gt__(other: object) -> bool

Enable > comparison for precedence.

Source code in provide/foundation/config/types.py
def __gt__(self, other: object) -> bool:
    """Enable > comparison for precedence."""
    if not isinstance(other, ConfigSource):
        return NotImplemented
    return self.value > other.value
__le__
__le__(other: object) -> bool

Enable <= comparison for precedence.

Source code in provide/foundation/config/types.py
def __le__(self, other: object) -> bool:
    """Enable <= comparison for precedence."""
    if not isinstance(other, ConfigSource):
        return NotImplemented
    return self.value <= other.value
__lt__
__lt__(other: object) -> bool

Enable comparison for precedence.

Source code in provide/foundation/config/types.py
def __lt__(self, other: object) -> bool:
    """Enable comparison for precedence."""
    if not isinstance(other, ConfigSource):
        return NotImplemented
    return self.value < other.value