Skip to content

Commit

Permalink
Improve documentation and remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jochemvandooren committed Mar 13, 2024
1 parent 37c0a01 commit 8811c28
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/dbt_score/rule.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down Expand Up @@ -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,),
Expand Down

0 comments on commit 8811c28

Please sign in to comment.