Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions inflect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2671,13 +2671,19 @@ def get_count(self, count: Optional[Union[str, int]] = None) -> Union[str, int]:
count = self.persistent_count

if count is not None:
count_text = str(count)
count = (
1
if (
(str(count) in pl_count_one)
(
isinstance(count, Number)
and not isinstance(count, bool)
and count == 1
)
or (count_text in pl_count_one)
or (
self.classical_dict["zero"]
and str(count).lower() in pl_count_zero
and count_text.lower() in pl_count_zero
)
)
else 2
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def test_pl(self):

for sing, num, plur in (
("cow", 1, "cow"),
("cow", 1.0, "cow"),
("cow", 2, "cows"),
("cow", "one", "cow"),
("cow", "each", "cow"),
Expand Down Expand Up @@ -534,6 +535,7 @@ def test_count(self):
p = inflect.engine()
for txt, num in (
(1, 1),
(1.0, 1),
(2, 2),
(0, 2),
(87, 2),
Expand Down