Skip to content

decorators

πŸ€– AI-Generated Content

This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.

pyvider.data_sources.decorators

Functions

register_data_source

register_data_source(
    name: str,
    component_of: str | None = None,
    test_only: bool = False,
) -> Callable[[type], type]

Decorator to register a data source and associate it with a capability.

Source code in pyvider/data_sources/decorators.py
def register_data_source(
    name: str, component_of: str | None = None, test_only: bool = False
) -> Callable[[type], type]:
    """
    Decorator to register a data source and associate it with a capability.
    """

    def decorator(cls: type) -> type:
        cls._is_registered_data_source = True  # type: ignore[attr-defined]
        cls._registered_name = name  # type: ignore[attr-defined]
        cls._is_test_only = test_only  # type: ignore[attr-defined]
        if component_of:
            cls._parent_capability = component_of  # type: ignore[attr-defined]
        logger.debug(
            f"πŸ“Š Marked data source '{name}' for discovery",
            capability=component_of,
            test_only=test_only,
        )
        return cls

    return decorator