Skip to content

Commit

Permalink
Simplify float validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
molisani authored Oct 11, 2022
1 parent bdeae2a commit 9172033
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pygtfs/gtfs_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 9172033

Please sign in to comment.