Skip to content

Commit

Permalink
Fix ConfigWarning not calling class method of child classes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathan-eq committed Oct 2, 2024
1 parent 398ce6a commit f6b86c6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ert/config/parsing/config_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f6b86c6

Please sign in to comment.