Skip to content

Commit 23e2698

Browse files
amyfromandigithub-actions[bot]
authored andcommitted
Format code and sort imports
1 parent a004d6c commit 23e2698

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

services/api-v3/api/routes/dev_routes/convert.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, List, Union, Optional
1+
from typing import Any, Iterable, List, Optional, Union
22

33
import dotenv
44
import httpx
@@ -54,6 +54,7 @@ def _dt_to_ms(dt: Optional[datetime]) -> Optional[int]:
5454
dt = dt.replace(tzinfo=timezone.utc)
5555
return int(dt.timestamp() * 1000)
5656

57+
5758
def _dt_to_iso_z(dt: Optional[datetime]) -> Optional[str]:
5859
if not dt:
5960
return None
@@ -62,7 +63,6 @@ def _dt_to_iso_z(dt: Optional[datetime]) -> Optional[str]:
6263
return dt.astimezone(timezone.utc).isoformat().replace("+00:00", "Z")
6364

6465

65-
6666
def _format_checkin_date(dt: Optional[datetime]) -> Optional[str]:
6767
"""Match example Rockd checkin date strings like 'October 19, 2023'."""
6868
if not dt:
@@ -287,25 +287,27 @@ def multiple_spot_to_fieldsite(
287287
return out
288288

289289

290-
def spot_to_checkin(spot: Union[dict, List[dict]] = Body(...)) -> Union[dict, list[dict]]:
290+
def spot_to_checkin(
291+
spot: Union[dict, List[dict]] = Body(...)
292+
) -> Union[dict, list[dict]]:
291293
"""Pipeline: Spot JSON (FeatureCollections) or FieldSites -> Checkin(s).
292294
Output rule:
293295
- dict output only when the input is a single object representing a single spot/fieldsite
294296
(Feature OR FeatureCollection with exactly 1 feature OR single FieldSite dict)
295297
AND exactly one checkin is produced.
296298
- otherwise list output
297299
"""
298-
#multiple fieldsites
300+
# multiple fieldsites
299301
if isinstance(spot, list):
300302
if spot and isinstance(spot[0], dict) and "location" in spot[0]:
301303
return multiple_fieldsite_to_rockd_checkin(spot)
302304
fieldsites = multiple_spot_to_fieldsite(spot)
303305
return multiple_fieldsite_to_rockd_checkin(fieldsites)
304-
#single fieldsite object
306+
# single fieldsite object
305307
if isinstance(spot, dict) and "location" in spot:
306308
checkins = multiple_fieldsite_to_rockd_checkin([spot])
307309
return checkins[0] if len(checkins) == 1 else checkins
308-
#determine whether this is a single spot
310+
# determine whether this is a single spot
309311
is_single_spot_payload = False
310312
if isinstance(spot, dict):
311313
t = spot.get("type")
@@ -322,8 +324,6 @@ def spot_to_checkin(spot: Union[dict, List[dict]] = Body(...)) -> Union[dict, li
322324
return checkins
323325

324326

325-
326-
327327
# ___________________________________CHECKIN - FS - SPOT____________________________________
328328
def checkin_to_fieldsite(checkin: dict) -> FieldSite:
329329
"""
@@ -360,10 +360,11 @@ def checkin_to_fieldsite(checkin: dict) -> FieldSite:
360360
observations.append(Observation(data=planar))
361361
created = _parse_date_time(checkin.get("created")) or datetime.now(timezone.utc)
362362

363-
updated = (_parse_date_time(checkin.get("updated"))
364-
or _parse_date_time(checkin.get("added"))
365-
or created
366-
)
363+
updated = (
364+
_parse_date_time(checkin.get("updated"))
365+
or _parse_date_time(checkin.get("added"))
366+
or created
367+
)
367368

368369
return FieldSite(
369370
id=int(cid),

0 commit comments

Comments
 (0)