Skip to content

Commit e89c8c8

Browse files
authored
Merge pull request #241 from samueljsb/remove-deprecated-private-function-aliases
2 parents 309e7fd + 79a4d48 commit e89c8c8

2 files changed

Lines changed: 1 addition & 160 deletions

File tree

src/humanize/i18n.py

Lines changed: 1 addition & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Activate, get and deactivate translations."""
22
import gettext as gettext_module
33
import os.path
4-
import warnings
54
from threading import local
65

7-
__all__ = ["activate", "deactivate", "gettext", "ngettext", "thousands_separator"]
6+
__all__ = ["activate", "deactivate", "thousands_separator"]
87

98
_TRANSLATIONS = {None: gettext_module.NullTranslations()}
109
_CURRENT = local()
@@ -79,26 +78,6 @@ def _gettext(message):
7978
return get_translation().gettext(message)
8079

8180

82-
def gettext(message):
83-
"""Get translation.
84-
85-
Args:
86-
message (str): Text to translate.
87-
88-
Returns:
89-
str: Translated text.
90-
91-
WARNING: This function has been deprecated. It is still available as the private
92-
member `_gettext`.
93-
"""
94-
warnings.warn(
95-
"`gettext` has been deprecated. "
96-
"It is still available as the private member `_gettext`.",
97-
DeprecationWarning,
98-
)
99-
return _gettext(message)
100-
101-
10281
def _pgettext(msgctxt, message):
10382
"""Fetches a particular translation.
10483
@@ -124,30 +103,6 @@ def _pgettext(msgctxt, message):
124103
return message if translation == key else translation
125104

126105

127-
def pgettext(msgctxt, message):
128-
"""Fetches a particular translation.
129-
130-
It works with `msgctxt` .po modifiers and allows duplicate keys with different
131-
translations.
132-
133-
Args:
134-
msgctxt (str): Context of the translation.
135-
message (str): Text to translate.
136-
137-
Returns:
138-
str: Translated text.
139-
140-
WARNING: This function has been deprecated. It is still available as the private
141-
member `_pgettext`.
142-
"""
143-
warnings.warn(
144-
"`pgettext` has been deprecated. "
145-
"It is still available as the private member `_pgettext`.",
146-
DeprecationWarning,
147-
)
148-
return _pgettext(msgctxt, message)
149-
150-
151106
def _ngettext(message, plural, num):
152107
"""Plural version of _gettext.
153108
@@ -163,29 +118,6 @@ def _ngettext(message, plural, num):
163118
return get_translation().ngettext(message, plural, num)
164119

165120

166-
def ngettext(msgctxt, message):
167-
"""Plural version of gettext.
168-
169-
Args:
170-
message (str): Singular text to translate.
171-
plural (str): Plural text to translate.
172-
num (str): The number (e.g. item count) to determine translation for the
173-
respective grammatical number.
174-
175-
Returns:
176-
str: Translated text.
177-
178-
WARNING: This function has been deprecated. It is still available as the private
179-
member `_ngettext`.
180-
"""
181-
warnings.warn(
182-
"`ngettext` has been deprecated. "
183-
"It is still available as the private member `_ngettext`.",
184-
DeprecationWarning,
185-
)
186-
return _ngettext(msgctxt, message)
187-
188-
189121
def _gettext_noop(message):
190122
"""Mark a string as a translation string without translating it.
191123
@@ -205,33 +137,6 @@ def num_name(n):
205137
return message
206138

207139

208-
def gettext_noop(message):
209-
"""Mark a string as a translation string without translating it.
210-
211-
Example usage:
212-
```python
213-
CONSTANTS = [_gettext_noop('first'), _gettext_noop('second')]
214-
def num_name(n):
215-
return _gettext(CONSTANTS[n])
216-
```
217-
218-
Args:
219-
message (str): Text to translate in the future.
220-
221-
Returns:
222-
str: Original text, unchanged.
223-
224-
WARNING: This function has been deprecated. It is still available as the private
225-
member `_gettext_noop`.
226-
"""
227-
warnings.warn(
228-
"`gettext_noop` has been deprecated. "
229-
"It is still available as the private member `_gettext_noop`.",
230-
DeprecationWarning,
231-
)
232-
return _gettext_noop(message)
233-
234-
235140
def _ngettext_noop(singular, plural):
236141
"""Mark two strings as pluralized translations without translating them.
237142
@@ -252,34 +157,6 @@ def num_name(n):
252157
return (singular, plural)
253158

254159

255-
def ngettext_noop(singular, plural):
256-
"""Mark two strings as pluralized translations without translating them.
257-
258-
Example usage:
259-
```python
260-
CONSTANTS = [ngettext_noop('first', 'firsts'), ngettext_noop('second', 'seconds')]
261-
def num_name(n):
262-
return _ngettext(*CONSTANTS[n])
263-
```
264-
265-
Args:
266-
singular (str): Singular text to translate in the future.
267-
plural (str): Plural text to translate in the future.
268-
269-
Returns:
270-
tuple: Original text, unchanged.
271-
272-
WARNING: This function has been deprecated. It is still available as the private
273-
member `_ngettext_noop`.
274-
"""
275-
warnings.warn(
276-
"`ngettext_noop` has been deprecated. "
277-
"It is still available as the private member `_ngettext_noop`.",
278-
DeprecationWarning,
279-
)
280-
return _ngettext_noop(singular, plural)
281-
282-
283160
def thousands_separator() -> str:
284161
"""Return the thousands separator for a locale, default to comma.
285162

src/humanize/time.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,6 @@ def _abs_timedelta(delta):
6060
return delta
6161

6262

63-
def abs_timedelta(delta):
64-
"""Return an "absolute" value for a timedelta, always representing a time distance.
65-
66-
Args:
67-
delta (datetime.timedelta): Input timedelta.
68-
69-
Returns:
70-
datetime.timedelta: Absolute timedelta.
71-
72-
WARNING: This function has been deprecated. It is still available as the private
73-
member `_abs_timedelta`.
74-
"""
75-
warnings.warn(
76-
"`abs_timedelta` has been deprecated. "
77-
"It is still available as the private member `_abs_timedelta`.",
78-
DeprecationWarning,
79-
)
80-
return _abs_timedelta(delta)
81-
82-
8363
def _date_and_delta(value, *, now=None):
8464
"""Turn a value into a date and a timedelta which represents how long ago it was.
8565
@@ -103,22 +83,6 @@ def _date_and_delta(value, *, now=None):
10383
return date, _abs_timedelta(delta)
10484

10585

106-
def date_and_delta(delta):
107-
"""Turn a value into a date and a timedelta which represents how long ago it was.
108-
109-
If that's not possible, return `(None, value)`.
110-
111-
WARNING: This function has been deprecated. It is still available as the private
112-
member `_date_and_delta`.
113-
"""
114-
warnings.warn(
115-
"`date_and_delta` has been deprecated. "
116-
"It is still available as the private member `_date_and_delta`.",
117-
DeprecationWarning,
118-
)
119-
return _date_and_delta(delta)
120-
121-
12286
def naturaldelta(
12387
value,
12488
months=True,

0 commit comments

Comments
 (0)