From b5ff990d93a61de67a6abcee14bc9cc47bac16c9 Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 09:14:45 +0200 Subject: [PATCH 1/6] Moved `FutureWarnings` for plugins Moved `FutureWarnings` from `deprecated_decorators.py` to `_config_parser.py`. --- webviz_config/_config_parser.py | 9 +++++++++ webviz_config/deprecation_decorators.py | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/webviz_config/_config_parser.py b/webviz_config/_config_parser.py index 60c9c762..a87babff 100644 --- a/webviz_config/_config_parser.py +++ b/webviz_config/_config_parser.py @@ -122,6 +122,15 @@ def _call_signature( ) if deprecated_plugin: deprecation_warnings.append(deprecated_plugin.short_message) + warnings.warn( + f"""Plugin {deprecated_plugin.class_reference} has been deprecated. +------------------------ +{deprecated_plugin.short_message} +=== +{deprecated_plugin.long_message} +""", + FutureWarning, + ) deprecations = _ds.DEPRECATION_STORE.get_stored_plugin_argument_deprecations( getattr(webviz_config.plugins, plugin_name).__init__ diff --git a/webviz_config/deprecation_decorators.py b/webviz_config/deprecation_decorators.py index 1486c8b6..e1095aea 100644 --- a/webviz_config/deprecation_decorators.py +++ b/webviz_config/deprecation_decorators.py @@ -1,6 +1,5 @@ from typing import Dict, Union, Callable, Tuple, cast, Optional, List import inspect -import warnings from ._plugin_abc import WebvizPluginABC from . import _deprecation_store as _ds @@ -21,16 +20,6 @@ def wrapper( ) ) - warnings.warn( - f"""Plugin {original_plugin} has been deprecated. ------------------------- -{short_message} -=== -{long_message} -""", - FutureWarning, - ) - return original_plugin return wrapper From ac1c4e3bfa1d79ba37d8d64a3b2ef9d4841e494e Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 11:30:42 +0200 Subject: [PATCH 2/6] Adjusted according to review comments. --- webviz_config/_config_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webviz_config/_config_parser.py b/webviz_config/_config_parser.py index a87babff..5f87a58d 100644 --- a/webviz_config/_config_parser.py +++ b/webviz_config/_config_parser.py @@ -123,7 +123,7 @@ def _call_signature( if deprecated_plugin: deprecation_warnings.append(deprecated_plugin.short_message) warnings.warn( - f"""Plugin {deprecated_plugin.class_reference} has been deprecated. + f"""Plugin '{plugin_name}' has been deprecated. ------------------------ {deprecated_plugin.short_message} === @@ -146,7 +146,7 @@ def _call_signature( if deprecation.argument_name in kwargs_including_defaults.keys(): deprecation_warnings.append(deprecation.short_message) warnings.warn( - """Deprecated Argument: {} with value '{}' in method {} in module {} + """Deprecated Argument: '{}' with value '{}' in method '{}' in module '{}' ------------------------ {} === @@ -173,7 +173,7 @@ def _call_signature( if result: deprecation_warnings.append(result[0]) warnings.warn( - """Deprecated Argument(s): {} with value '{}' in method {} in module {} + """Deprecated Argument(s): '{}' with value(s) '{}' in method '{}' in module '{}' ------------------------ {} === From ff52083e232c43297ed1403d158cae41088e3e50 Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 12:29:16 +0200 Subject: [PATCH 3/6] Adjusted changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24705fb2..2d2d411c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] - YYYY-MM-DD +### Changed +- [#429](https://github.com/equinor/webviz-config/pull/429) - Moved `FutureWarnings` +from `deprecated_decorators.py` to `_config_parser.py`. + ## [0.3.0] - 2021-04-27 ### Added From bd8be889c2f655a511e2608d074915ae163383b4 Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 13:54:59 +0200 Subject: [PATCH 4/6] Changed -> Fixed --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d2d411c..a620ebd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] - YYYY-MM-DD -### Changed +### Fixed - [#429](https://github.com/equinor/webviz-config/pull/429) - Moved `FutureWarnings` from `deprecated_decorators.py` to `_config_parser.py`. From 3a5c631db4e5d69f87bcdbb0eda89fc48ffb8ebb Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 14:21:45 +0200 Subject: [PATCH 5/6] Simplified deprecation warning messages --- webviz_config/_config_parser.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/webviz_config/_config_parser.py b/webviz_config/_config_parser.py index 5f87a58d..499a00a2 100644 --- a/webviz_config/_config_parser.py +++ b/webviz_config/_config_parser.py @@ -146,7 +146,7 @@ def _call_signature( if deprecation.argument_name in kwargs_including_defaults.keys(): deprecation_warnings.append(deprecation.short_message) warnings.warn( - """Deprecated Argument: '{}' with value '{}' in method '{}' in module '{}' + """Deprecated Argument: '{}' with value '{}' in plugin '{}' ------------------------ {} === @@ -154,8 +154,7 @@ def _call_signature( """.format( deprecation.argument_name, kwargs_including_defaults[deprecation.argument_name], - deprecation.method_name, - getattr(deprecation.method_reference, "__module__"), + plugin_name, deprecation.short_message, deprecation.long_message, ), @@ -173,7 +172,7 @@ def _call_signature( if result: deprecation_warnings.append(result[0]) warnings.warn( - """Deprecated Argument(s): '{}' with value(s) '{}' in method '{}' in module '{}' + """Deprecated Argument(s): '{}' with value(s) '{}' in plugin '{}' ------------------------ {} === @@ -185,8 +184,7 @@ def _call_signature( for key, value in kwargs_including_defaults.items() if key in deprecation.argument_names ], - deprecation.method_name, - getattr(deprecation.method_reference, "__module__"), + plugin_name, result[0], result[1], ), From c9be9f1f9770cd4f42a61e5a686d41303f2b52ac Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Wed, 28 Apr 2021 14:22:40 +0200 Subject: [PATCH 6/6] Adjusted changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a620ebd7..127500ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [#429](https://github.com/equinor/webviz-config/pull/429) - Moved `FutureWarnings` -from `deprecated_decorators.py` to `_config_parser.py`. +from `deprecated_decorators.py` to `_config_parser.py`. Simplified deprecation warnings. ## [0.3.0] - 2021-04-27