mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 15:12:20 +00:00 
			
		
		
		
	#707: Don't use @cache on methods
				
					
				
			This commit is contained in:
		| @@ -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() | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user