Skip to content

Commit 83caaf8

Browse files
authored
Moved FutureWarnings for plugins (#429)
* Moved `FutureWarnings` from `deprecated_decorators.py` to `_config_parser.py`. * Simplified deprecation warning messages.
1 parent 414d141 commit 83caaf8

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [UNRELEASED] - YYYY-MM-DD
88

9+
### Fixed
10+
- [#429](https://github.com/equinor/webviz-config/pull/429) - Moved `FutureWarnings`
11+
from `deprecated_decorators.py` to `_config_parser.py`. Simplified deprecation warnings.
12+
913
## [0.3.0] - 2021-04-27
1014

1115
### Added

webviz_config/_config_parser.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ def _call_signature(
122122
)
123123
if deprecated_plugin:
124124
deprecation_warnings.append(deprecated_plugin.short_message)
125+
warnings.warn(
126+
f"""Plugin '{plugin_name}' has been deprecated.
127+
------------------------
128+
{deprecated_plugin.short_message}
129+
===
130+
{deprecated_plugin.long_message}
131+
""",
132+
FutureWarning,
133+
)
125134

126135
deprecations = _ds.DEPRECATION_STORE.get_stored_plugin_argument_deprecations(
127136
getattr(webviz_config.plugins, plugin_name).__init__
@@ -137,16 +146,15 @@ def _call_signature(
137146
if deprecation.argument_name in kwargs_including_defaults.keys():
138147
deprecation_warnings.append(deprecation.short_message)
139148
warnings.warn(
140-
"""Deprecated Argument: {} with value '{}' in method {} in module {}
149+
"""Deprecated Argument: '{}' with value '{}' in plugin '{}'
141150
------------------------
142151
{}
143152
===
144153
{}
145154
""".format(
146155
deprecation.argument_name,
147156
kwargs_including_defaults[deprecation.argument_name],
148-
deprecation.method_name,
149-
getattr(deprecation.method_reference, "__module__"),
157+
plugin_name,
150158
deprecation.short_message,
151159
deprecation.long_message,
152160
),
@@ -164,7 +172,7 @@ def _call_signature(
164172
if result:
165173
deprecation_warnings.append(result[0])
166174
warnings.warn(
167-
"""Deprecated Argument(s): {} with value '{}' in method {} in module {}
175+
"""Deprecated Argument(s): '{}' with value(s) '{}' in plugin '{}'
168176
------------------------
169177
{}
170178
===
@@ -176,8 +184,7 @@ def _call_signature(
176184
for key, value in kwargs_including_defaults.items()
177185
if key in deprecation.argument_names
178186
],
179-
deprecation.method_name,
180-
getattr(deprecation.method_reference, "__module__"),
187+
plugin_name,
181188
result[0],
182189
result[1],
183190
),

webviz_config/deprecation_decorators.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Dict, Union, Callable, Tuple, cast, Optional, List
22
import inspect
3-
import warnings
43

54
from ._plugin_abc import WebvizPluginABC
65
from . import _deprecation_store as _ds
@@ -21,16 +20,6 @@ def wrapper(
2120
)
2221
)
2322

24-
warnings.warn(
25-
f"""Plugin {original_plugin} has been deprecated.
26-
------------------------
27-
{short_message}
28-
===
29-
{long_message}
30-
""",
31-
FutureWarning,
32-
)
33-
3423
return original_plugin
3524

3625
return wrapper

0 commit comments

Comments
 (0)