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

Moved FutureWarnings for plugins #429

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Fixed
- [#429](https://github.com/equinor/webviz-config/pull/429) - Moved `FutureWarnings`
from `deprecated_decorators.py` to `_config_parser.py`. Simplified deprecation warnings.

## [0.3.0] - 2021-04-27

### Added
Expand Down
19 changes: 13 additions & 6 deletions webviz_config/_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def _call_signature(
)
if deprecated_plugin:
deprecation_warnings.append(deprecated_plugin.short_message)
warnings.warn(
f"""Plugin '{plugin_name}' 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__
Expand All @@ -137,16 +146,15 @@ 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 '{}'
------------------------
{}
===
{}
""".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,
),
Expand All @@ -164,7 +172,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 plugin '{}'
------------------------
{}
===
Expand All @@ -176,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],
),
Expand Down
11 changes: 0 additions & 11 deletions webviz_config/deprecation_decorators.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down