From 8811c28986ae1085c70f8df84b36069ca0174ae6 Mon Sep 17 00:00:00 2001 From: Jochem van Dooren Date: Wed, 13 Mar 2024 15:25:12 +0100 Subject: [PATCH] Improve documentation and remove logging --- src/dbt_score/rule.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/dbt_score/rule.py b/src/dbt_score/rule.py index 6148989..43cd06a 100644 --- a/src/dbt_score/rule.py +++ b/src/dbt_score/rule.py @@ -1,17 +1,12 @@ """Rule definitions.""" import functools -import logging from dataclasses import dataclass from enum import Enum from typing import Any, Callable, Type from dbt_score.models import Model -logging.basicConfig() -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - class Severity(Enum): """The severity/weight of a rule.""" @@ -65,16 +60,17 @@ def decorator_rule( ) -> Type[Rule]: @functools.wraps(func) def wrapper_rule(*args: Any, **kwargs: Any) -> Any: - logger.debug("Executing `%s` with severity: %s.", func.__name__, severity) return func(*args, **kwargs) - # Create the rule class if func.__doc__ is None and description is None: raise TypeError("Rule must define `description` or `func.__doc__`.") + # Get description parameter, otherwise use the docstring. rule_description = description or ( func.__doc__.split("\n")[0] if func.__doc__ else None ) + + # Create the rule class inheriting from Rule. rule_class = type( func.__name__, (Rule,),