You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/07/15 17:34:11 UTC

(tooling-trusted-release) branch main updated: Use a more reliable approach to construct Release instances

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new ca5f176  Use a more reliable approach to construct Release instances
ca5f176 is described below

commit ca5f176bc670f5a5a78290f858c9fef0f728b5d6
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Tue Jul 15 18:33:43 2025 +0100

    Use a more reliable approach to construct Release instances
---
 atr/models/api.py |  5 -----
 atr/models/sql.py | 15 ++++++---------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/atr/models/api.py b/atr/models/api.py
index 4311afc..70c3036 100644
--- a/atr/models/api.py
+++ b/atr/models/api.py
@@ -229,11 +229,6 @@ class ReleasesProjectResults(schema.Strict):
     data: Sequence[sql.Release]
     count: int
 
-    @pydantic.field_validator("data", mode="before")
-    @classmethod
-    def coerce_release(cls, v: Sequence[dict[str, Any]]) -> Sequence[sql.Release]:
-        return [sql.Release.model_validate(item) if isinstance(item, dict) else item for item in v]
-
 
 class ReleasesVersionResults(schema.Strict):
     endpoint: Literal["/releases/version"] = schema.Field(alias="endpoint")
diff --git a/atr/models/sql.py b/atr/models/sql.py
index d2c91b2..802e349 100644
--- a/atr/models/sql.py
+++ b/atr/models/sql.py
@@ -597,15 +597,12 @@ class Release(sqlmodel.SQLModel, table=True):
             raise ValueError("Latest revision number is not a str or None")
         return number
 
-    @pydantic.field_validator("created", mode="before")
-    @classmethod
-    def parse_created(cls, v: str | datetime.datetime):
-        return datetime.datetime.fromisoformat(v.rstrip("Z")) if isinstance(v, str) else v
-
-    @pydantic.field_validator("phase", mode="before")
-    @classmethod
-    def parse_phase(cls, v: str | ReleasePhase):
-        return ReleasePhase(v) if isinstance(v, str) else v
+    def model_post_init(self, _context):
+        if isinstance(self.created, str):
+            self.created = datetime.datetime.fromisoformat(self.created.rstrip("Z"))
+
+        if isinstance(self.phase, str):
+            self.phase = ReleasePhase(self.phase)
 
     # NOTE: This does not work
     # But it we set it with Release.latest_revision_number_query = ..., it might work


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org