From a13b0a41731e2d8ada0a78bb93472ea106cd77cd Mon Sep 17 00:00:00 2001 From: Dan Yeaw Date: Thu, 11 May 2023 20:55:54 -0400 Subject: [PATCH] Change logging to debug level --- generic/multidispatch.py | 4 +++- generic/multimethod.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/generic/multidispatch.py b/generic/multidispatch.py index d154357..c818469 100644 --- a/generic/multidispatch.py +++ b/generic/multidispatch.py @@ -23,6 +23,8 @@ __all__ = "multidispatch" T = TypeVar("T", bound=Union[Callable[..., Any], type]) KeyType = Union[type, None] +logger = logging.getLogger(__name__) + def multidispatch(*argtypes: KeyType) -> Callable[[T], FunctionDispatcher[T]]: """Declare function as multidispatch. @@ -127,7 +129,7 @@ class FunctionDispatcher(Generic[T]): trimmed_args = args[: self.params_arity] rule = self.registry.lookup(*trimmed_args) if not rule: - logging.error(self.registry._tree) + logger.debug(self.registry._tree) raise TypeError(f"No available rule found for {trimmed_args!r}") return rule(*args, **kwargs) diff --git a/generic/multimethod.py b/generic/multimethod.py index 59acdfa..cdb6096 100644 --- a/generic/multimethod.py +++ b/generic/multimethod.py @@ -17,6 +17,8 @@ __all__ = ("multimethod", "has_multimethods") C = TypeVar("C") T = TypeVar("T", bound=Union[Callable[..., Any], type]) +logger = logging.getLogger(__name__) + def multimethod(*argtypes: KeyType) -> Callable[[T], MethodDispatcher[T]]: """Declare method as multimethod. @@ -82,7 +84,7 @@ class MethodDispatcher(FunctionDispatcher[T]): """Process all unbound rule by binding them to ``cls`` type.""" for argtypes, func in self.local.unbound_rules: argtypes = (cls,) + argtypes - logging.info("register rule", argtypes) + logger.debug("register rule", argtypes) self.register_rule(func, *argtypes) self.local.unbound_rules = []