From f2f0826fb513c1c94599d07a2aa2604aefc703b5 Mon Sep 17 00:00:00 2001 From: Viktor Bozhinov Date: Wed, 8 Dec 2021 10:28:10 +0000 Subject: [PATCH] refactor: reference not-yet constructed models using string #264 --- datagateway_api/src/search_api/models.py | 27 +++++++++--------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/datagateway_api/src/search_api/models.py b/datagateway_api/src/search_api/models.py index 1a6f6274..dc3d30c0 100644 --- a/datagateway_api/src/search_api/models.py +++ b/datagateway_api/src/search_api/models.py @@ -1,10 +1,3 @@ -""" -Code to define the PaNOSC data model -TODO - Implement these using pydantic -""" - -from __future__ import annotations - from abc import ABC, abstractclassmethod, abstractmethod from datetime import datetime from decimal import Decimal @@ -40,7 +33,7 @@ class Affiliation(PaNOSCAttribute): city: Optional[StrictStr] country: Optional[StrictStr] - members: Optional[List[Member]] + members: Optional[List["Member"]] @classmethod def from_icat(cls): @@ -62,12 +55,12 @@ class Dataset(PaNOSCAttribute): creation_date: datetime = Field(alias="creationDate") score: Decimal - documents: List[Document] - techniques: List[Technique] - instrument: Optional[instrument] - files: Optional[List[File]] - parameters: Optional[List[Parameter]] - samples: Optional[List[Sample]] + documents: List["Document"] + techniques: List["Technique"] + instrument: Optional["instrument"] + files: Optional[List["File"]] + parameters: Optional[List["Parameter"]] + samples: Optional[List["Sample"]] @classmethod def from_icat(cls): @@ -96,8 +89,8 @@ class Document(PaNOSCAttribute): score: Decimal datasets: List[Dataset] - members: Optional[List[Member]] - parameters: Optional[List[Parameter]] + members: Optional[List["Member"]] + parameters: Optional[List["Parameter"]] @classmethod def from_icat(cls): @@ -151,7 +144,7 @@ class Member(PaNOSCAttribute): # Should a member be able to be part of many documents? document: Document - person: Optional[Person] + person: Optional["Person"] affiliations: Optional[List[Affiliation]] @classmethod