Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated private function aliases #241

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 1 addition & 124 deletions src/humanize/i18n.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Activate, get and deactivate translations."""
import gettext as gettext_module
import os.path
import warnings
from threading import local

__all__ = ["activate", "deactivate", "gettext", "ngettext", "thousands_separator"]
__all__ = ["activate", "deactivate", "thousands_separator"]

_TRANSLATIONS = {None: gettext_module.NullTranslations()}
_CURRENT = local()
Expand Down Expand Up @@ -79,26 +78,6 @@ def _gettext(message):
return get_translation().gettext(message)


def gettext(message):
"""Get translation.

Args:
message (str): Text to translate.

Returns:
str: Translated text.

WARNING: This function has been deprecated. It is still available as the private
member `_gettext`.
"""
warnings.warn(
"`gettext` has been deprecated. "
"It is still available as the private member `_gettext`.",
DeprecationWarning,
)
return _gettext(message)


def _pgettext(msgctxt, message):
"""Fetches a particular translation.

Expand All @@ -124,30 +103,6 @@ def _pgettext(msgctxt, message):
return message if translation == key else translation


def pgettext(msgctxt, message):
"""Fetches a particular translation.

It works with `msgctxt` .po modifiers and allows duplicate keys with different
translations.

Args:
msgctxt (str): Context of the translation.
message (str): Text to translate.

Returns:
str: Translated text.

WARNING: This function has been deprecated. It is still available as the private
member `_pgettext`.
"""
warnings.warn(
"`pgettext` has been deprecated. "
"It is still available as the private member `_pgettext`.",
DeprecationWarning,
)
return _pgettext(msgctxt, message)


def _ngettext(message, plural, num):
"""Plural version of _gettext.

Expand All @@ -163,29 +118,6 @@ def _ngettext(message, plural, num):
return get_translation().ngettext(message, plural, num)


def ngettext(msgctxt, message):
"""Plural version of gettext.

Args:
message (str): Singular text to translate.
plural (str): Plural text to translate.
num (str): The number (e.g. item count) to determine translation for the
respective grammatical number.

Returns:
str: Translated text.

WARNING: This function has been deprecated. It is still available as the private
member `_ngettext`.
"""
warnings.warn(
"`ngettext` has been deprecated. "
"It is still available as the private member `_ngettext`.",
DeprecationWarning,
)
return _ngettext(msgctxt, message)


def _gettext_noop(message):
"""Mark a string as a translation string without translating it.

Expand All @@ -205,33 +137,6 @@ def num_name(n):
return message


def gettext_noop(message):
"""Mark a string as a translation string without translating it.

Example usage:
```python
CONSTANTS = [_gettext_noop('first'), _gettext_noop('second')]
def num_name(n):
return _gettext(CONSTANTS[n])
```

Args:
message (str): Text to translate in the future.

Returns:
str: Original text, unchanged.

WARNING: This function has been deprecated. It is still available as the private
member `_gettext_noop`.
"""
warnings.warn(
"`gettext_noop` has been deprecated. "
"It is still available as the private member `_gettext_noop`.",
DeprecationWarning,
)
return _gettext_noop(message)


def _ngettext_noop(singular, plural):
"""Mark two strings as pluralized translations without translating them.

Expand All @@ -252,34 +157,6 @@ def num_name(n):
return (singular, plural)


def ngettext_noop(singular, plural):
"""Mark two strings as pluralized translations without translating them.

Example usage:
```python
CONSTANTS = [ngettext_noop('first', 'firsts'), ngettext_noop('second', 'seconds')]
def num_name(n):
return _ngettext(*CONSTANTS[n])
```

Args:
singular (str): Singular text to translate in the future.
plural (str): Plural text to translate in the future.

Returns:
tuple: Original text, unchanged.

WARNING: This function has been deprecated. It is still available as the private
member `_ngettext_noop`.
"""
warnings.warn(
"`ngettext_noop` has been deprecated. "
"It is still available as the private member `_ngettext_noop`.",
DeprecationWarning,
)
return _ngettext_noop(singular, plural)


def thousands_separator() -> str:
"""Return the thousands separator for a locale, default to comma.

Expand Down
36 changes: 0 additions & 36 deletions src/humanize/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,6 @@ def _abs_timedelta(delta):
return delta


def abs_timedelta(delta):
"""Return an "absolute" value for a timedelta, always representing a time distance.

Args:
delta (datetime.timedelta): Input timedelta.

Returns:
datetime.timedelta: Absolute timedelta.

WARNING: This function has been deprecated. It is still available as the private
member `_abs_timedelta`.
"""
warnings.warn(
"`abs_timedelta` has been deprecated. "
"It is still available as the private member `_abs_timedelta`.",
DeprecationWarning,
)
return _abs_timedelta(delta)


def _date_and_delta(value, *, now=None):
"""Turn a value into a date and a timedelta which represents how long ago it was.

Expand All @@ -103,22 +83,6 @@ def _date_and_delta(value, *, now=None):
return date, _abs_timedelta(delta)


def date_and_delta(delta):
"""Turn a value into a date and a timedelta which represents how long ago it was.

If that's not possible, return `(None, value)`.

WARNING: This function has been deprecated. It is still available as the private
member `_date_and_delta`.
"""
warnings.warn(
"`date_and_delta` has been deprecated. "
"It is still available as the private member `_date_and_delta`.",
DeprecationWarning,
)
return _date_and_delta(delta)


def naturaldelta(
value,
months=True,
Expand Down