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 |
|---|---|
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,
Attach a
ConfigPropertyto an existingConfigGroupsubclass.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 plainsetattr, so a directly-assigned descriptor would leaveConfigProperty._nameempty (breakingobject_property_nameand Object-schema serialization). This helper wires it up correctly.For class-body declarations (the usual case in a subsystem’s own
ConfigGroupsubclass), keep using the normalfoo: T = ConfigProperty(OPT)form —__set_name__fires automatically at class creation.