77
88import datetime as dt
99import math
10- import warnings
11- from enum import Enum , EnumMeta
10+ from enum import Enum
1211from functools import total_ordering
1312
1413from .i18n import _gettext as _
@@ -40,43 +39,6 @@ def __lt__(self, other):
4039 return NotImplemented
4140
4241
43- class _UnitMeta (EnumMeta ):
44- """Metaclass for an enum that emits deprecation warnings when accessed."""
45-
46- def __getattribute__ (self , name ):
47- warnings .warn (
48- "`Unit` has been deprecated. "
49- "The enum is still available as the private member `_Unit`." ,
50- DeprecationWarning ,
51- )
52- return EnumMeta .__getattribute__ (_Unit , name )
53-
54- def __getitem__ (cls , name ):
55- warnings .warn (
56- "`Unit` has been deprecated. "
57- "The enum is still available as the private member `_Unit`." ,
58- DeprecationWarning ,
59- )
60- return _Unit .__getitem__ (name )
61-
62- def __call__ (
63- cls , value , names = None , * , module = None , qualname = None , type = None , start = 1
64- ):
65- warnings .warn (
66- "`Unit` has been deprecated. "
67- "The enum is still available as the private member `_Unit`." ,
68- DeprecationWarning ,
69- )
70- return _Unit .__call__ (
71- value , names , module = module , qualname = qualname , type = type , start = start
72- )
73-
74-
75- class Unit (Enum , metaclass = _UnitMeta ):
76- # Temporary alias for _Unit to allow backwards-compatible usage.
77- pass
78-
79-
8042def _now ():
8143 return dt .datetime .now ()
8244
@@ -96,26 +58,6 @@ def _abs_timedelta(delta):
9658 return delta
9759
9860
99- def abs_timedelta (delta ):
100- """Return an "absolute" value for a timedelta, always representing a time distance.
101-
102- Args:
103- delta (datetime.timedelta): Input timedelta.
104-
105- Returns:
106- datetime.timedelta: Absolute timedelta.
107-
108- WARNING: This function has been deprecated. It is still available as the private
109- member `_abs_timedelta`.
110- """
111- warnings .warn (
112- "`abs_timedelta` has been deprecated. "
113- "It is still available as the private member `_abs_timedelta`." ,
114- DeprecationWarning ,
115- )
116- return _abs_timedelta (delta )
117-
118-
11961def _date_and_delta (value , * , now = None ):
12062 """Turn a value into a date and a timedelta which represents how long ago it was.
12163
@@ -139,22 +81,6 @@ def _date_and_delta(value, *, now=None):
13981 return date , _abs_timedelta (delta )
14082
14183
142- def date_and_delta (delta ):
143- """Turn a value into a date and a timedelta which represents how long ago it was.
144-
145- If that's not possible, return `(None, value)`.
146-
147- WARNING: This function has been deprecated. It is still available as the private
148- member `_date_and_delta`.
149- """
150- warnings .warn (
151- "`date_and_delta` has been deprecated. "
152- "It is still available as the private member `_date_and_delta`." ,
153- DeprecationWarning ,
154- )
155- return _date_and_delta (delta )
156-
157-
15884def naturaldelta (
15985 value ,
16086 months = True ,
0 commit comments