Skip to content

Commit 1d8f864

Browse files
committed
Restore Met Office numeric field parsing
1 parent 256c2be commit 1d8f864

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

publishers/met_office_datahub/met_office_datahub_publisher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def _parse_source_time(raw_time: str) -> tuple[float, str]:
109109
def _as_float(value) -> float | None:
110110
if value is None or value == "":
111111
return None
112+
try:
113+
return float(value)
114+
except (TypeError, ValueError):
115+
return None
112116

113117

114118
_CARDINAL_DEGREES = {
@@ -146,10 +150,6 @@ def _numeric_value_for_parameter(value, parameter: dict) -> float | None:
146150
if output_name == "pressure_tendency" and isinstance(value, str):
147151
return _PRESSURE_TENDENCY_CODES.get(value.strip().upper())
148152
return _as_float(value)
149-
try:
150-
return float(value)
151-
except (TypeError, ValueError):
152-
return None
153153

154154

155155
def _retry_after_seconds(error: HTTPError) -> float | None:

0 commit comments

Comments
 (0)