##// END OF EJS Templates
Add deprecation docstrings and warning.
Nils Müller -
Show More
@@ -3,6 +3,8 b''
3 3 Timezone utilities
4 4
5 5 Just UTC-awareness right now
6
7 Deprecated since IPython 8.19.0.
6 8 """
7 9
8 10 # -----------------------------------------------------------------------------
@@ -16,17 +18,35 b' Just UTC-awareness right now'
16 18 # Imports
17 19 # -----------------------------------------------------------------------------
18 20
21 import warnings
19 22 from datetime import tzinfo, timedelta, datetime
20 23
21 24 # -----------------------------------------------------------------------------
22 25 # Code
23 26 # -----------------------------------------------------------------------------
27
28 __all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
29
24 30 # constant for zero offset
25 31 ZERO = timedelta(0)
26 32
27 33
34 def __getattr__(name):
35 if name not in __all__:
36 err = f"IPython.utils.tz is deprecated and has no attribute {name}"
37 raise AttributeError(err)
38
39 msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
40 warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
41
42 return getattr(name)
43
44
28 45 class tzUTC(tzinfo):
29 """tzinfo object for UTC (zero offset)"""
46 """tzinfo object for UTC (zero offset)
47
48 Deprecated since IPython 8.19.0.
49 """
30 50
31 51 def utcoffset(self, d):
32 52 return ZERO
@@ -39,7 +59,10 b' UTC = tzUTC() # type: ignore[abstract]'
39 59
40 60
41 61 def utc_aware(unaware):
42 """decorator for adding UTC tzinfo to datetime's utcfoo methods"""
62 """decorator for adding UTC tzinfo to datetime's utcfoo methods
63
64 Deprecated since IPython 8.19.0.
65 """
43 66
44 67 def utc_method(*args, **kwargs):
45 68 dt = unaware(*args, **kwargs)
General Comments 0
You need to be logged in to leave comments. Login now