From 04360cdfe7a78367c8b574022cf6569f95d56db3 Mon Sep 17 00:00:00 2001 From: Mike Morearty Date: Sun, 22 Oct 2017 17:15:42 -0700 Subject: [PATCH] Load from cache even when code was given Change Grammar._parse() to try load_module() even if code was passed to it. In many cases, _parse() is passed both the code and the path to the .py file. E.g. in jedi-vim if you type "import foo.", then every .py file in directory "foo" will reach Grammar._parse() with both the `code` and the `path` variables filled in. This change allows the cache to be used in those cases. --- parso/grammar.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/parso/grammar.py b/parso/grammar.py index a886b67..0f72703 100644 --- a/parso/grammar.py +++ b/parso/grammar.py @@ -94,10 +94,7 @@ class Grammar(object): if error_recovery and start_symbol != 'file_input': raise NotImplementedError("This is currently not implemented.") - if cache and code is None and path is not None: - # With the current architecture we cannot load from cache if the - # code is given, because we just load from cache if it's not older than - # the latest change (file last modified). + if cache and path is not None: module_node = load_module(self._hashed, path, cache_path=cache_path) if module_node is not None: return module_node