Skip to content

Commit

Permalink
Use warnings module for deprecation warning (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
coroa authored Oct 30, 2020
1 parent f071e79 commit 2a569ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Individual updates

- [#445](https://github.com/IAMconsortium/pyam/pull/445) Prevent conflicts between attributes and data/meta columns
- [#444](https://github.com/IAMconsortium/pyam/pull/444) Use warnings module for deprecation warnings

# Release v0.8.0

Expand Down
7 changes: 6 additions & 1 deletion pyam/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from contextlib import contextmanager
import logging
import warnings

logger = logging.getLogger(__name__)

Expand All @@ -15,4 +16,8 @@ def adjust_log_level(logger, level='ERROR'):
def deprecation_warning(msg, type='This method'):
"""Write deprecation warning to log"""
warn = 'is deprecated and will be removed in future versions.'
logger.warning('{} {} {}'.format(type, warn, msg))
warnings.warn(
'{} {} {}'.format(type, warn, msg),
DeprecationWarning,
stacklevel=3
)

0 comments on commit 2a569ff

Please sign in to comment.