From a712c5d42c567751be0949a2202f48d138547c25 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 2 Jan 2023 08:44:00 +0100 Subject: [PATCH] Improve if formatting --- freqtrade/strategy/strategyupdater.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/freqtrade/strategy/strategyupdater.py b/freqtrade/strategy/strategyupdater.py index ab757e0a9..a0547932c 100644 --- a/freqtrade/strategy/strategyupdater.py +++ b/freqtrade/strategy/strategyupdater.py @@ -184,9 +184,11 @@ class NameUpdater(ast.NodeTransformer): def visit_Attribute(self, node): # if the attribute name is 'nr_of_successful_buys', # update it to 'nr_of_successful_entries' - if isinstance(node.value, ast.Name) and \ - node.value.id == 'trades' and \ - node.attr == 'nr_of_successful_buys': + if ( + isinstance(node.value, ast.Name) + and node.value.id == 'trades' + and node.attr == 'nr_of_successful_buys' + ): node.attr = 'nr_of_successful_entries' return self.generic_visit(node) @@ -208,9 +210,11 @@ class NameUpdater(ast.NodeTransformer): # otherwise, update its value to 3 else: for child in node.body: - if isinstance(child, ast.Assign) and \ - isinstance(child.targets[0], ast.Name) and \ - child.targets[0].id == 'INTERFACE_VERSION': + if ( + isinstance(child, ast.Assign) + and isinstance(child.targets[0], ast.Name) + and child.targets[0].id == 'INTERFACE_VERSION' + ): child.value = ast.parse('3').body[0].value return self.generic_visit(node) @@ -253,8 +257,6 @@ class NameUpdater(ast.NodeTransformer): def visit_Constant(self, node): # do not update the names in import statements - if node.value in \ - StrategyUpdater.otif_ot_unfilledtimeout: - node.value = \ - StrategyUpdater.otif_ot_unfilledtimeout[node.value] + if node.value in StrategyUpdater.otif_ot_unfilledtimeout: + node.value = StrategyUpdater.otif_ot_unfilledtimeout[node.value] return node