From 99e3badbad1c22ba35f080559ee358787fc6b24f Mon Sep 17 00:00:00 2001 From: axif Date: Mon, 24 Nov 2025 02:10:41 +0600 Subject: [PATCH] Modernize _delete_entity with Literal typing and f-string formatting --- 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 83bbf0497..f9abd73c1 100644 --- a/openml/study/study.py +++ b/openml/study/study.py @@ -147,22 +147,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 {