From b5c8350d95ab02dbf78d496b2565c04281a7a1ae Mon Sep 17 00:00:00 2001 From: Shelly Chahar Date: Tue, 22 Sep 2026 19:58:10 +0530 Subject: [PATCH] [MNT] Use walrus operator in study.py to resolve TODO Signed-off-by: Shelly Chahar --- openml/study/study.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openml/study/study.py b/openml/study/study.py index 803c6455b..9614efa23 100644 --- a/openml/study/study.py +++ b/openml/study/study.py @@ -148,22 +148,18 @@ def _to_dict(self) -> dict[str, dict]: # some can not be uploaded, e.g., id, creator, creation_date simple_props = ["alias", "main_entity_type", "name", "description"] - # TODO(eddiebergman): Begging for a walrus if we can drop 3.7 simple_prop_values = {} for prop_name in simple_props: - content = getattr(self, prop_name, None) - if content is not None: + if (content := getattr(self, prop_name, None)) is not None: simple_prop_values["oml:" + prop_name] = content # maps from attribute name (which is used as outer tag name) to immer # tag name e.g., self.tasks -> 1987 complex_props = {"tasks": "task_id", "runs": "run_id"} - # TODO(eddiebergman): Begging for a walrus if we can drop 3.7 complex_prop_values = {} for prop_name, inner_name in complex_props.items(): - content = getattr(self, prop_name, None) - if content is not None: + if (content := getattr(self, prop_name, None)) is not None: complex_prop_values["oml:" + prop_name] = {"oml:" + inner_name: content} return {