From f6b86c6e7a2efa302bf42b0048f19295a6af99b2 Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Wed, 2 Oct 2024 13:15:47 +0200 Subject: [PATCH] Fix ConfigWarning not calling class method of child classes This commit fixes an issue where the parent class `ConfigWarning` has all methods decorated with `staticmethod`, rather than `classmethod`. The class methods should call the child class's method implementation where they are implemented. --- src/ert/config/parsing/config_errors.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ert/config/parsing/config_errors.py b/src/ert/config/parsing/config_errors.py index 7b15efc61f8..4ff733dfd1f 100644 --- a/src/ert/config/parsing/config_errors.py +++ b/src/ert/config/parsing/config_errors.py @@ -12,20 +12,20 @@ class ConfigWarning(UserWarning): info: WarningInfo - @staticmethod - def warn(message: str, context: MaybeWithContext = "") -> None: - ConfigWarning._formatted_warn(ConfigWarning.with_context(message, context)) + @classmethod + def warn(cls, message: str, context: MaybeWithContext = "") -> None: + cls._formatted_warn(cls.with_context(message, context)) - @staticmethod - def deprecation_warn(message: str, context: MaybeWithContext = "") -> None: - warning = ConfigWarning.with_context(message, context) + @classmethod + def deprecation_warn(cls, message: str, context: MaybeWithContext = "") -> None: + warning = cls.with_context(message, context) if not hasattr(context, "token"): warning.info.set_context_keyword(context) warning.info.is_deprecation = True - ConfigWarning._formatted_warn(warning) + cls._formatted_warn(warning) - @staticmethod - def _formatted_warn(config_warning: ConfigWarning) -> None: + @classmethod + def _formatted_warn(cls, config_warning: ConfigWarning) -> None: temp = warnings.formatwarning def ert_formatted_warning(