Skip to content

Commit b3b2bc8

Browse files
refactor: Explicitly convert input to float once and streamline exception handling in to_cardinal_float.
1 parent 99087ce commit b3b2bc8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

num2words/lang_SN.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ def to_cardinal(self, value):
201201
def to_cardinal_float(self, value):
202202
"""Convert a float to its Shona word representation."""
203203
try:
204-
float(value) == value
205-
except (ValueError, TypeError, AssertionError, AttributeError):
204+
value = float(value)
205+
except (ValueError, TypeError, AttributeError):
206206
raise TypeError(self.errmsg_nonnum % value)
207207

208-
pre, post = self.float2tuple(float(value))
208+
pre, post = self.float2tuple(value)
209209
post = str(post)
210210
post = '0' * (self.precision - len(post)) + post
211211

0 commit comments

Comments
 (0)