Repository navigation
Fix Interval.in_words() singular unit for sub-second intervals - #1109
Open
Yasser-Ameur wants to merge 1 commit into
Open
Yasser-Ameur wants to merge 1 commit into
Yasser-Ameur wants to merge 1 commit into
Conversation
Interval.in_words() returned "0.12 second" for an interval of 123456 microseconds, while Duration.in_words() returns "0.12 seconds". python-pendulum#826 changed the sub-second branch of Duration.in_words() to use plural(0), but Interval overrides in_words() with its own copy of that code, which still used plural(1). Its test asserted the old singular. Use plural(0) in Interval.in_words(), as Duration does, and update the test expectation to "0.12 seconds".
Yasser-Ameur
marked this pull request as ready for review
December 5, 2026 02:51
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Interval.in_words()prints a singular unit for a sub-second interval, whileDuration.in_words()prints the plural.Cause
#826 changed the sub-second branch of
Duration.in_words()toplural(0).Intervalcarries its own copy ofin_words()insrc/pendulum/interval.py, which keptplural(1), and its test asserted the singular.Change
The branch uses
plural(0), exactly asDuration.in_words()does. One line in the library. I did not check other locales; the plural form is whateverDurationalready uses for each of them.Tests
I changed the expectation in
test_subsecondsintests/interval/test_in_words.pyfrom"0.12 second"to"0.12 seconds", mirroring theDurationtest. It fails on master withassert '0.12 second' == '0.12 seconds'.Run locally on Python 3.14 against the worktree sources:
pytest -q testsgives 1 failed, 1867 passed, 5 skipped, 1 warning. The one failure istests/test_main.py::test_instance_with_aware_datetime_any_tzinfo, which depends on the host timezone and fails without this change too (open PR #1072 covers it).mypy(strict) reports no issues in 228 source files, andruff checkandruff format --checkare clean (ruff 0.14.11).The same suite with
PENDULUM_EXTENSIONS=0gives the same result.Not run: other Python versions. I did not edit
CHANGELOG.md, since recent PRs do not touch it.Pull Request Check List
The existing test was updated rather than a new one added. No documentation describes the old output. This is a bug fix, so it is based on
master.