Source code for aeat.core.observability._redaction_rules
"""Lazily-resolved :class:`SensitivityClass` DIAGNOSTIC redaction rule set.The :func:`diagnostic_rules` helper resolves the DIAGNOSTIC-class ruleset lazily on first call so the observability package does not pull:mod:`aeat.adapters.persistence.storage` (which triggers Alembic plugindiscovery and emits INFO log lines on stderr at import time) into everyCLI command's import chain. The cost of resolving the rule set once isnegligible compared with one-time Alembic discovery."""from__future__importannotationsfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:from..classificationimportRedactionRule# Cached at module scope after first resolution so repeated emits do not# re-import the redaction substrate._DIAGNOSTIC_RULES:tuple[RedactionRule,...]|None=None
[docs]defdiagnostic_rules()->tuple[RedactionRule,...]:"""Return the DIAGNOSTIC-class default rule set, resolved on first call. Cached at module scope after first resolution so repeated emits do not re-import the redaction substrate. Returns: A tuple of :class:`RedactionRule` instances for the ``DIAGNOSTIC`` sensitivity class. """global_DIAGNOSTIC_RULESif_DIAGNOSTIC_RULESisNone:from..classificationimportSensitivityClassfrom..redactionimportdefault_rules_for_class_DIAGNOSTIC_RULES=default_rules_for_class(SensitivityClass.DIAGNOSTIC)return_DIAGNOSTIC_RULES