Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ConfigWarning not calling class method of child classes #8845

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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