mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
Create SIGRef objects when converting dict to Spot object in the spot object's own __post_init__ method rather than in add_spot.py
This commit is contained in:
@@ -133,6 +133,17 @@ class Spot:
|
||||
# The ID the source gave it, if any.
|
||||
source_id: str | None = None
|
||||
|
||||
def __post_init__(self):
|
||||
"""Normalise fields that don't survive a plain dict to Spot conversion. This is used in the "add spot" API
|
||||
endpoint where the client is submitting JSON, and we want to recreate a full Spot object, including nested
|
||||
objects such as the sig_refs list.."""
|
||||
|
||||
if self.sig_refs:
|
||||
self.sig_refs = [
|
||||
sig_ref if isinstance(sig_ref, SIGRef) else SIGRef(**sig_ref)
|
||||
for sig_ref in self.sig_refs
|
||||
]
|
||||
|
||||
def infer_missing(self, credentials=None):
|
||||
"""Infer missing parameters where possible"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user