From f3c1917280b4e56c0771152893422ed2a2394d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Sat, 23 Nov 2024 23:26:46 +0100 Subject: [PATCH] using walrus operator to simplify logic in GraphCreatorFactory --- shaketune/graph_creators/graph_creator_factory.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shaketune/graph_creators/graph_creator_factory.py b/shaketune/graph_creators/graph_creator_factory.py index ba2d41b..b3b3362 100644 --- a/shaketune/graph_creators/graph_creator_factory.py +++ b/shaketune/graph_creators/graph_creator_factory.py @@ -14,7 +14,7 @@ class GraphCreatorFactory: @staticmethod def create_graph_creator(graph_type: str, config: ShakeTuneConfig) -> GraphCreator: - creator_class = GraphCreator.registry.get(graph_type, None) - if not creator_class: + if creator_class := GraphCreator.registry.get(graph_type): + return creator_class(config) + else: raise NotImplementedError(f'Graph creator for {graph_type} not implemented!') - return creator_class(config)