Created
February 14, 2022 19:12
-
-
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`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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