Skip to content

Commit b86bfda

Browse files
authored
Merge pull request #208 from WhyNotHugo/typing
2 parents 99b68f6 + 05a0c58 commit b86bfda

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/humanize/time.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ def date_and_delta(value, *, now=None):
8181
return date, abs_timedelta(delta)
8282

8383

84-
def naturaldelta(value, months=True, minimum_unit="seconds", when=None):
84+
def naturaldelta(
85+
value,
86+
months=True,
87+
minimum_unit="seconds",
88+
when=None,
89+
) -> str:
8590
"""Return a natural representation of a timedelta or number of seconds.
8691
8792
This is similar to `naturaltime`, but does not add tense to the result.
@@ -187,7 +192,13 @@ def naturaldelta(value, months=True, minimum_unit="seconds", when=None):
187192
return ngettext("%d year", "%d years", years) % years
188193

189194

190-
def naturaltime(value, future=False, months=True, minimum_unit="seconds", when=None):
195+
def naturaltime(
196+
value,
197+
future=False,
198+
months=True,
199+
minimum_unit="seconds",
200+
when=None,
201+
) -> str:
191202
"""Return a natural representation of a time in a resolution that makes sense.
192203
193204
This is more or less compatible with Django's `naturaltime` filter.
@@ -223,7 +234,7 @@ def naturaltime(value, future=False, months=True, minimum_unit="seconds", when=N
223234
return ago % delta
224235

225236

226-
def naturalday(value, format="%b %d"):
237+
def naturalday(value, format="%b %d") -> str:
227238
"""Return a natural day.
228239
229240
For date values that are tomorrow, today or yesterday compared to
@@ -249,7 +260,7 @@ def naturalday(value, format="%b %d"):
249260
return value.strftime(format)
250261

251262

252-
def naturaldate(value):
263+
def naturaldate(value) -> str:
253264
"""Like `naturalday`, but append a year for dates more than ~five months away."""
254265
try:
255266
value = dt.date(value.year, value.month, value.day)
@@ -375,7 +386,7 @@ def _suppress_lower_units(min_unit, suppress):
375386
return suppress
376387

377388

378-
def precisedelta(value, minimum_unit="seconds", suppress=(), format="%0.2f"):
389+
def precisedelta(value, minimum_unit="seconds", suppress=(), format="%0.2f") -> str:
379390
"""Return a precise representation of a timedelta.
380391
381392
```pycon

0 commit comments

Comments
 (0)