From a30d72974fe94a459066c85299e20206dd2efcee Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Tue, 17 Mar 2026 14:58:42 -0300 Subject: [PATCH 1/2] Clarify LoggerMixin usage in docstrings Document that self.log is the preferred way to access the logger from instance methods, and cls.logger() should only be used in classmethods or static contexts where self is unavailable. --- src/palace/manager/util/log.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/palace/manager/util/log.py b/src/palace/manager/util/log.py index 301453cfeb..2396c17b50 100644 --- a/src/palace/manager/util/log.py +++ b/src/palace/manager/util/log.py @@ -107,7 +107,11 @@ def logger_for_cls(cls: type[object]) -> logging.Logger: class LoggerMixin: - """Mixin that adds a logger with a standardized name""" + """Mixin that adds a logger with a standardized name. + + Use ``self.log`` from instance methods and ``cls.logger()`` from + classmethods or static contexts where ``self`` is unavailable. + """ @classmethod @functools.cache @@ -117,14 +121,16 @@ def logger(cls) -> logging.Logger: This is cached so that we don't create a new logger every time it is called. + + Prefer ``self.log`` when calling from an instance method. + Use ``cls.logger()`` only in classmethods or static contexts. """ return logger_for_cls(cls) @property def log(self) -> LoggerType: """ - A convenience property that returns the logger for the class, - so it is easier to access the logger from an instance. + The preferred way to access the logger from instance methods. """ return self.logger() From e6ed8e809dc62f8d4faf4e47ee4d7c5752bb1725 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Tue, 17 Mar 2026 15:01:55 -0300 Subject: [PATCH 2/2] Make the doc comments less repetitive --- src/palace/manager/util/log.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/palace/manager/util/log.py b/src/palace/manager/util/log.py index 2396c17b50..01d12e7f0b 100644 --- a/src/palace/manager/util/log.py +++ b/src/palace/manager/util/log.py @@ -107,11 +107,7 @@ def logger_for_cls(cls: type[object]) -> logging.Logger: class LoggerMixin: - """Mixin that adds a logger with a standardized name. - - Use ``self.log`` from instance methods and ``cls.logger()`` from - classmethods or static contexts where ``self`` is unavailable. - """ + """Mixin that adds a logger with a standardized name.""" @classmethod @functools.cache