From d228091beb0050d3dcde3a3551612700a93470f1 Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Tue, 10 Oct 2017 19:15:36 +0200 Subject: [PATCH] #707: Don't use `@cache` on methods --- thefuck/shells/fish.py | 12 ++++++++---- thefuck/utils.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/thefuck/shells/fish.py b/thefuck/shells/fish.py index a104d43d..56ad2145 100644 --- a/thefuck/shells/fish.py +++ b/thefuck/shells/fish.py @@ -9,6 +9,13 @@ from ..utils import DEVNULL, cache from .generic import Generic +@cache('~/.config/fish/config.fish', '~/.config/fish/functions') +def _get_aliases(overridden): + proc = Popen(['fish', '-ic', 'functions'], stdout=PIPE, stderr=DEVNULL) + functions = proc.stdout.read().decode('utf-8').strip().split('\n') + return {func: func for func in functions if func not in overridden} + + class Fish(Generic): def _get_overridden_aliases(self): overridden = os.environ.get('THEFUCK_OVERRIDDEN_ALIASES', @@ -35,12 +42,9 @@ class Fish(Generic): ' end\n' 'end').format(alias_name, alter_history) - @cache('~/.config/fish/config.fish', '~/.config/fish/functions') def get_aliases(self): overridden = self._get_overridden_aliases() - proc = Popen(['fish', '-ic', 'functions'], stdout=PIPE, stderr=DEVNULL) - functions = proc.stdout.read().decode('utf-8').strip().split('\n') - return {func: func for func in functions if func not in overridden} + return _get_aliases(overridden) def _expand_aliases(self, command_script): aliases = self.get_aliases() diff --git a/thefuck/utils.py b/thefuck/utils.py index 5927a2c0..ad136769 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -254,7 +254,7 @@ def cache(*depends_on): Cache will be expired when modification date of files from `depends_on` will be changed. - Function wrapped in `cache` should be arguments agnostic. + Only functions should be wrapped in `cache`, not methods. """ def cache_decorator(fn):