Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c00a14

Browse files
author
Nils Müller
committed
Add _warn_deprecated()
1 parent fa928a4 commit 6c00a14

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

IPython/utils/tz.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
# -----------------------------------------------------------------------------
2525
# Code
2626
# -----------------------------------------------------------------------------
27-
2827
__all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
2928

29+
# Enable display of DeprecrationWarning for this module explicitly.
30+
warnings.filterwarnings("default", category=DeprecationWarning, module=__name__)
31+
3032
# constant for zero offset
3133
ZERO = timedelta(0)
3234

@@ -36,18 +38,24 @@ def __getattr__(name):
3638
err = f"IPython.utils.tz is deprecated and has no attribute {name}"
3739
raise AttributeError(err)
3840

39-
msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
40-
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
41+
_warn_deprecated()
4142

4243
return getattr(name)
4344

4445

46+
def _warn_deprecated():
47+
msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
48+
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
49+
50+
4551
class tzUTC(tzinfo):
4652
"""tzinfo object for UTC (zero offset)
4753
4854
Deprecated since IPython 8.19.0.
4955
"""
5056

57+
_warn_deprecated()
58+
5159
def utcoffset(self, d):
5260
return ZERO
5361

@@ -65,6 +73,7 @@ def utc_aware(unaware):
6573
"""
6674

6775
def utc_method(*args, **kwargs):
76+
_warn_deprecated()
6877
dt = unaware(*args, **kwargs)
6978
return dt.replace(tzinfo=UTC)
7079

0 commit comments

Comments
 (0)