diff --git a/IPython/utils/tz.py b/IPython/utils/tz.py index 40dc62e..653e3a8 100644 --- a/IPython/utils/tz.py +++ b/IPython/utils/tz.py @@ -24,9 +24,11 @@ from datetime import tzinfo, timedelta, datetime # ----------------------------------------------------------------------------- # Code # ----------------------------------------------------------------------------- - __all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"] +# Enable display of DeprecrationWarning for this module explicitly. +warnings.filterwarnings("default", category=DeprecationWarning, module=__name__) + # constant for zero offset ZERO = timedelta(0) @@ -36,18 +38,24 @@ def __getattr__(name): err = f"IPython.utils.tz is deprecated and has no attribute {name}" raise AttributeError(err) - msg = "The module `IPython.utils.tz` is deprecated and will be completely removed." - warnings.warn(msg, category=DeprecationWarning, stacklevel=2) + _warn_deprecated() return getattr(name) +def _warn_deprecated(): + msg = "The module `IPython.utils.tz` is deprecated and will be completely removed." + warnings.warn(msg, category=DeprecationWarning, stacklevel=2) + + class tzUTC(tzinfo): """tzinfo object for UTC (zero offset) Deprecated since IPython 8.19.0. """ + _warn_deprecated() + def utcoffset(self, d): return ZERO @@ -65,6 +73,7 @@ def utc_aware(unaware): """ def utc_method(*args, **kwargs): + _warn_deprecated() dt = unaware(*args, **kwargs) return dt.replace(tzinfo=UTC)