tlcconfig.group¶

Configuration group base class.

A ConfigGroup is a namespace that holds ConfigProperty descriptors but delegates all storage and notification to a parent Configuration object. This gives typed, nested access (config.service.port) while keeping a single centralized cache.

.. rubric:: Example

class ServiceConfig(ConfigGroup):
    port: int = ConfigProperty(SERVICE_PORT, validate=ConfigLogic.is_valid_port)
    host: str = ConfigProperty(SERVICE_HOST)

class Configuration:
    def __init__(self):
        self.service = ServiceConfig(self)

Module Contents¶

Classes¶

Class

Description

ConfigGroup

Namespace that delegates storage and notifications to a parent Configuration.

API¶

class ConfigGroup(
parent: Any,
)¶

Namespace that delegates storage and notifications to a parent Configuration.

ConfigProperty descriptors on a ConfigGroup call _get_value/_set_value, which this class forwards to the parent. The parent owns the cache, the notification system, and the dirty/timestamp tracking.

classmethod add_property(
name: str,
option: Option[Any],
*,
transform: Callable[[Any, ConfigSource, str | None], Any] | None = None,
validate: Callable[[Any], bool] | None = None,
) ConfigProperty[Any]¶

Attach a ConfigProperty to an existing ConfigGroup subclass.

Use this when a subsystem needs to extend a group after class creation — e.g. a plugin module registers options against a group owned by another package. Python’s descriptor protocol does not invoke __set_name__ on plain setattr, so a directly-assigned descriptor would leave ConfigProperty._name empty (breaking object_property_name and Object-schema serialization). This helper wires it up correctly.

For class-body declarations (the usual case in a subsystem’s own ConfigGroup subclass), keep using the normal foo: T = ConfigProperty(OPT) form — __set_name__ fires automatically at class creation.