Skip to content

Commit

Permalink
DOC: Deprecate naturaldelta(when)
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Dec 14, 2021
1 parent 429e3d8 commit bbdd173
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/humanize/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def naturaldelta(
minimum_unit (str): The lowest unit that can be used.
when (datetime.datetime): Point in time relative to which _value_ is
interpreted. Defaults to the current time in the local timezone.
.. deprecated:: 3.13
If you need to construct a timedelta, do it inline as the first
argument.
Returns:
str: A natural representation of the amount of time elapsed.
Expand All @@ -189,6 +192,14 @@ def naturaldelta(
assert naturaldelta(later, when=now) == "30 minutes"
"""
if when:
warnings.warn(
"The `when` parameter of naturaldelta() is deprecated and will be "
"removed in humanize 4.0. If you need to construct a timedelta, "
"do it inline as the first argument.",
DeprecationWarning,
stacklevel=2,
)
tmp = _Unit[minimum_unit.upper()]
if tmp not in (_Unit.SECONDS, _Unit.MILLISECONDS, _Unit.MICROSECONDS):
raise ValueError(f"Minimum unit '{minimum_unit}' not supported")
Expand Down

0 comments on commit bbdd173

Please sign in to comment.