From b5b2e089cbbf80089b96d063a435fc783f8cb261 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Mon, 22 Jun 2026 11:38:59 +0200 Subject: [PATCH] Handle float one counts --- inflect/__init__.py | 10 ++++++++-- tests/test_pwd.py | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/inflect/__init__.py b/inflect/__init__.py index 3eef486b..9db92e32 100644 --- a/inflect/__init__.py +++ b/inflect/__init__.py @@ -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 diff --git a/tests/test_pwd.py b/tests/test_pwd.py index 630b0658..c5bdbdc2 100644 --- a/tests/test_pwd.py +++ b/tests/test_pwd.py @@ -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"), @@ -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),