Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@malcolmgreaves
Created February 14, 2022 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcolmgreaves/59fa64d7f334f6c448ba49d41070067f to your computer and use it in GitHub Desktop.
Save malcolmgreaves/59fa64d7f334f6c448ba49d41070067f to your computer and use it in GitHub Desktop.
Convenience function for a deprecation warning. Logs a message both as a warning as well as using the `warnings` package's `DeprecationWarning`.
import logging
import warnings
def deprecation_warning(logger: logging.Logger, msg: str) -> None:
"""Creates a deprecation warning log event with given the message and logger.
Convenience function for a deprecation warning. Logs a message both as a warning
as well as using the `warnings` package's `DeprecationWarning`.
"""
logger.warning(msg)
warnings.simplefilter("always", DeprecationWarning)
warnings.warn(msg, DeprecationWarning)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment