##// END OF EJS Templates
Add _warn_deprecated()
Nils Müller -
Show More
@@ -24,9 +24,11 b' from datetime import tzinfo, timedelta, datetime'
24 # -----------------------------------------------------------------------------
24 # -----------------------------------------------------------------------------
25 # Code
25 # Code
26 # -----------------------------------------------------------------------------
26 # -----------------------------------------------------------------------------
27
28 __all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
27 __all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
29
28
29 # Enable display of DeprecrationWarning for this module explicitly.
30 warnings.filterwarnings("default", category=DeprecationWarning, module=__name__)
31
30 # constant for zero offset
32 # constant for zero offset
31 ZERO = timedelta(0)
33 ZERO = timedelta(0)
32
34
@@ -36,18 +38,24 b' def __getattr__(name):'
36 err = f"IPython.utils.tz is deprecated and has no attribute {name}"
38 err = f"IPython.utils.tz is deprecated and has no attribute {name}"
37 raise AttributeError(err)
39 raise AttributeError(err)
38
40
39 msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
41 _warn_deprecated()
40 warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
41
42
42 return getattr(name)
43 return getattr(name)
43
44
44
45
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
45 class tzUTC(tzinfo):
51 class tzUTC(tzinfo):
46 """tzinfo object for UTC (zero offset)
52 """tzinfo object for UTC (zero offset)
47
53
48 Deprecated since IPython 8.19.0.
54 Deprecated since IPython 8.19.0.
49 """
55 """
50
56
57 _warn_deprecated()
58
51 def utcoffset(self, d):
59 def utcoffset(self, d):
52 return ZERO
60 return ZERO
53
61
@@ -65,6 +73,7 b' def utc_aware(unaware):'
65 """
73 """
66
74
67 def utc_method(*args, **kwargs):
75 def utc_method(*args, **kwargs):
76 _warn_deprecated()
68 dt = unaware(*args, **kwargs)
77 dt = unaware(*args, **kwargs)
69 return dt.replace(tzinfo=UTC)
78 return dt.replace(tzinfo=UTC)
70
79
General Comments 0
You need to be logged in to leave comments. Login now