mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +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 | 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): | class Fish(Generic): | ||||||
|     def _get_overridden_aliases(self): |     def _get_overridden_aliases(self): | ||||||
|         overridden = os.environ.get('THEFUCK_OVERRIDDEN_ALIASES', |         overridden = os.environ.get('THEFUCK_OVERRIDDEN_ALIASES', | ||||||
| @@ -35,12 +42,9 @@ class Fish(Generic): | |||||||
|                 '  end\n' |                 '  end\n' | ||||||
|                 'end').format(alias_name, alter_history) |                 'end').format(alias_name, alter_history) | ||||||
|  |  | ||||||
|     @cache('~/.config/fish/config.fish', '~/.config/fish/functions') |  | ||||||
|     def get_aliases(self): |     def get_aliases(self): | ||||||
|         overridden = self._get_overridden_aliases() |         overridden = self._get_overridden_aliases() | ||||||
|         proc = Popen(['fish', '-ic', 'functions'], stdout=PIPE, stderr=DEVNULL) |         return _get_aliases(overridden) | ||||||
|         functions = proc.stdout.read().decode('utf-8').strip().split('\n') |  | ||||||
|         return {func: func for func in functions if func not in overridden} |  | ||||||
|  |  | ||||||
|     def _expand_aliases(self, command_script): |     def _expand_aliases(self, command_script): | ||||||
|         aliases = self.get_aliases() |         aliases = self.get_aliases() | ||||||
|   | |||||||
| @@ -254,7 +254,7 @@ def cache(*depends_on): | |||||||
|     Cache will be expired when modification date of files from `depends_on` |     Cache will be expired when modification date of files from `depends_on` | ||||||
|     will be changed. |     will be changed. | ||||||
|  |  | ||||||
|     Function wrapped in `cache` should be arguments agnostic. |     Only functions should be wrapped in `cache`, not methods. | ||||||
|  |  | ||||||
|     """ |     """ | ||||||
|     def cache_decorator(fn): |     def cache_decorator(fn): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user