Skip to content

Commit cda8bf0

Browse files
committed
Improve grammar and consistency in some internal docstrings/comments.
1 parent 93aefff commit cda8bf0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/humanize/i18n.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ def _pgettext(msgctxt: str, message: str) -> str:
107107
return message if translation == key else translation
108108

109109

110-
def _ngettext(message: str, plural: str, num: int) -> str:
110+
def _ngettext(message: str, plural: str, num: int | float) -> str:
111111
"""Plural version of _gettext.
112112
113113
Args:
114114
message (str): Singular text to translate.
115115
plural (str): Plural text to translate.
116-
num (int): The number (e.g. item count) to determine translation for the
117-
respective grammatical number.
116+
num (int or float): The number (e.g. item count) to determine translation for
117+
the respective grammatical number.
118118
119119
Returns:
120120
str: Translated text.

src/humanize/time.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,25 +298,25 @@ def _quotient_and_remainder(
298298
minimum_unit: Unit,
299299
suppress: collections.abc.Iterable[Unit],
300300
) -> tuple[float, float]:
301-
"""Divide `value` by `divisor` returning the quotient and remainder.
301+
"""Divide `value` by `divisor`, returning the quotient and remainder.
302302
303-
If `unit` is `minimum_unit`, makes the quotient a float number and the remainder
304-
will be zero. The rational is that if `unit` is the unit of the quotient, we cannot
303+
If `unit` is `minimum_unit`, the quotient will be a float number and the remainder
304+
will be zero. The rationale is that if `unit` is the unit of the quotient, we cannot
305305
represent the remainder because it would require a unit smaller than the
306306
`minimum_unit`.
307307
308308
>>> from humanize.time import _quotient_and_remainder, Unit
309309
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.DAYS, [])
310310
(1.5, 0)
311311
312-
If unit is in `suppress`, the quotient will be zero and the remainder will be the
312+
If `unit` is in `suppress`, the quotient will be zero and the remainder will be the
313313
initial value. The idea is that if we cannot use `unit`, we are forced to use a
314-
lower unit so we cannot do the division.
314+
lower unit, so we cannot do the division.
315315
316316
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [Unit.DAYS])
317317
(0, 36)
318318
319-
In other case return quotient and remainder as `divmod` would do it.
319+
In other cases, return the quotient and remainder as `divmod` would do it.
320320
321321
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [])
322322
(1, 12)
@@ -340,16 +340,16 @@ def _carry(
340340
) -> tuple[float, float]:
341341
"""Return a tuple with two values.
342342
343-
If the unit is in `suppress`, multiply `value1` by `ratio` and add it to `value2`
344-
(carry to right). The idea is that if we cannot represent `value1` we need to
343+
If `unit` is in `suppress`, multiply `value1` by `ratio` and add it to `value2`
344+
(carry to right). The idea is that if we cannot represent `value1`, we need to
345345
represent it in a lower unit.
346346
347347
>>> from humanize.time import _carry, Unit
348348
>>> _carry(2, 6, 24, Unit.DAYS, Unit.SECONDS, [Unit.DAYS])
349349
(0, 54)
350350
351-
If the unit is the minimum unit, `value2` is divided by `ratio` and added to
352-
`value1` (carry to left). We assume that `value2` has a lower unit so we need to
351+
If `unit` is the minimum unit, divide `value2` by `ratio` and add it to `value1`
352+
(carry to left). We assume that `value2` has a lower unit, so we need to
353353
carry it to `value1`.
354354
355355
>>> _carry(2, 6, 24, Unit.DAYS, Unit.DAYS, [])
@@ -369,7 +369,7 @@ def _carry(
369369

370370

371371
def _suitable_minimum_unit(min_unit: Unit, suppress: typing.Iterable[Unit]) -> Unit:
372-
"""Return a minimum unit suitable that is not suppressed.
372+
"""Return a suitable minimum unit that is not suppressed.
373373
374374
If not suppressed, return the same unit:
375375
@@ -492,8 +492,8 @@ def precisedelta(
492492

493493
suppress_set = {Unit[s.upper()] for s in suppress}
494494

495-
# Find a suitable minimum unit (it can be greater the one that the
496-
# user gave us if it is suppressed).
495+
# Find a suitable minimum unit (it can be greater than the one that the
496+
# user gave us, if that one is suppressed).
497497
min_unit = Unit[minimum_unit.upper()]
498498
min_unit = _suitable_minimum_unit(min_unit, suppress_set)
499499
del minimum_unit
@@ -542,7 +542,7 @@ def precisedelta(
542542
usecs, 1000, MILLISECONDS, min_unit, suppress_set
543543
)
544544

545-
# if _unused != 0 we had lost some precision
545+
# if _unused != 0 we have lost some precision
546546
usecs, _unused = _carry(usecs, 0, 1, MICROSECONDS, min_unit, suppress_set)
547547

548548
fmts = [

0 commit comments

Comments
 (0)