From 76fb62ca4508252483f15b6434a2a5b63a200fff Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 29 Jan 2025 13:58:31 +0100 Subject: [PATCH] =?UTF-8?q?docs(events):=20improve=20TODO=20for=20?= =?UTF-8?q?=E2=80=B9project*=E2=80=BA=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested-by: Laura Barcziová Signed-off-by: Matej Focko --- packit_service/events/event_data.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packit_service/events/event_data.py b/packit_service/events/event_data.py index 5ac6ebebf..09dedfc1a 100644 --- a/packit_service/events/event_data.py +++ b/packit_service/events/event_data.py @@ -147,8 +147,19 @@ def project(self): return self._project def _add_project_object_and_event(self): - # TODO, do a better job - # Probably, try to recreate original classes. + # [TODO] Improve handling of this matching against hard-coded values. + # 1. Switching from hard-coded values to using ‹.event_type()› on the + # classes themselves would be possible, but that would introduce + # circular imports. + # 2. Better approach would be importing based on the ‹self.event_type› + # and inheriting a “mixin” within the event class that could handle + # this logic. However ‹self.project› (used below) is a property, and + # the return values are assigned to ‹self›. Also the type signature + # for the methods introduced by a mixin would be complicated, as the + # least amount of copy-paste basically leads to having both named + # arguments and ‹**kwargs› to catch any additional unused parameters. + # We would also lose silent fail on some of the currently ignored + # events (right now we log a warning). if self.event_type in { "github.pr.Action", "pagure.pr.Action",