From c0004cc63d30ac805f6862ec4989976f5aadd0e9 Mon Sep 17 00:00:00 2001 From: Julia Alexeeva Date: Tue, 26 Nov 2024 20:12:14 +0200 Subject: [PATCH] Removed redundant 'return', conditions in 'else/if' switched (to avoid using 'not'. --- app/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index ba812d26..055d04a3 100644 --- a/app/main.py +++ b/app/main.py @@ -5,10 +5,11 @@ def cache(func: Callable) -> Callable: storage = {} def wrapper(*args) -> Callable: - if args not in storage: - print("Calculating new result") - return storage.setdefault(args, func(*args)) - else: + if args in storage: print("Getting from cache") - return storage.get(args) + else: + print("Calculating new result") + storage.setdefault(args, func(*args)) + return storage.get(args) + return wrapper