55
66from __future__ import annotations
77
8- import collections .abc
98import datetime as dt
109import math
11- import typing
1210from enum import Enum
1311from functools import total_ordering
14- from typing import Any
1512
1613from .i18n import _gettext as _
1714from .i18n import _ngettext
1815from .number import intcomma
1916
17+ TYPE_CHECKING = False
18+ if TYPE_CHECKING :
19+ from collections .abc import Iterable
20+ from typing import Any
21+
2022__all__ = [
2123 "naturaldate" ,
2224 "naturalday" ,
@@ -37,7 +39,7 @@ class Unit(Enum):
3739 MONTHS = 6
3840 YEARS = 7
3941
40- def __lt__ (self , other : typing . Any ) -> typing . Any :
42+ def __lt__ (self , other : Any ) -> Any :
4143 if self .__class__ is other .__class__ :
4244 return self .value < other .value
4345 return NotImplemented
@@ -62,9 +64,7 @@ def _abs_timedelta(delta: dt.timedelta) -> dt.timedelta:
6264 return delta
6365
6466
65- def _date_and_delta (
66- value : typing .Any , * , now : dt .datetime | None = None
67- ) -> tuple [typing .Any , typing .Any ]:
67+ def _date_and_delta (value : Any , * , now : dt .datetime | None = None ) -> tuple [Any , Any ]:
6868 """Turn a value into a date and a timedelta which represents how long ago it was.
6969
7070 If that's not possible, return `(None, value)`.
@@ -327,7 +327,7 @@ def _quotient_and_remainder(
327327 divisor : float ,
328328 unit : Unit ,
329329 minimum_unit : Unit ,
330- suppress : collections . abc . Iterable [Unit ],
330+ suppress : Iterable [Unit ],
331331) -> tuple [float , float ]:
332332 """Divide `value` by `divisor` returning the quotient and remainder.
333333
@@ -368,7 +368,7 @@ def _carry(
368368 ratio : float ,
369369 unit : Unit ,
370370 min_unit : Unit ,
371- suppress : typing . Iterable [Unit ],
371+ suppress : Iterable [Unit ],
372372) -> tuple [float , float ]:
373373 """Return a tuple with two values.
374374
@@ -401,7 +401,7 @@ def _carry(
401401 return value1 , value2
402402
403403
404- def _suitable_minimum_unit (min_unit : Unit , suppress : typing . Iterable [Unit ]) -> Unit :
404+ def _suitable_minimum_unit (min_unit : Unit , suppress : Iterable [Unit ]) -> Unit :
405405 """Return a minimum unit suitable that is not suppressed.
406406
407407 If not suppressed, return the same unit:
@@ -430,7 +430,7 @@ def _suitable_minimum_unit(min_unit: Unit, suppress: typing.Iterable[Unit]) -> U
430430 return min_unit
431431
432432
433- def _suppress_lower_units (min_unit : Unit , suppress : typing . Iterable [Unit ]) -> set [Unit ]:
433+ def _suppress_lower_units (min_unit : Unit , suppress : Iterable [Unit ]) -> set [Unit ]:
434434 """Extend suppressed units (if any) with all units lower than the minimum unit.
435435
436436 >>> from humanize.time import _suppress_lower_units, Unit
@@ -449,7 +449,7 @@ def _suppress_lower_units(min_unit: Unit, suppress: typing.Iterable[Unit]) -> se
449449def precisedelta (
450450 value : dt .timedelta | int | None ,
451451 minimum_unit : str = "seconds" ,
452- suppress : typing . Iterable [str ] = (),
452+ suppress : Iterable [str ] = (),
453453 format : str = "%0.2f" ,
454454) -> str :
455455 """Return a precise representation of a timedelta.
0 commit comments