From 9172033abc0ad990cff78d3d26bdf9c8d26efbd4 Mon Sep 17 00:00:00 2001 From: Michael Molisani Date: Tue, 11 Oct 2022 15:53:40 -0700 Subject: [PATCH] Simplify float validation logic --- pygtfs/gtfs_entities.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pygtfs/gtfs_entities.py b/pygtfs/gtfs_entities.py index a84f015..8244006 100644 --- a/pygtfs/gtfs_entities.py +++ b/pygtfs/gtfs_entities.py @@ -82,13 +82,9 @@ def in_range(self, key, value): def _validate_float_none(*field_names): @validates(*field_names) def is_float_none(self, key, value): - try: - return float(value) - except ValueError: - if value is None or value == "": - return None - else: - raise + if value is None or value == "": + return None + return float(value) return is_float_none