Add the cache_path parameter to parso calls.

This commit is contained in:
Dave Halter
2017-05-20 10:08:48 -04:00
parent 50c7137437
commit f35f1b9676
5 changed files with 12 additions and 6 deletions

View File

@@ -141,6 +141,7 @@ class Script(object):
grammar=self._grammar, grammar=self._grammar,
cache=False, # No disk cache, because the current script often changes. cache=False, # No disk cache, because the current script often changes.
diff_cache=True, diff_cache=True,
cache_path=settings.cache_directory
) )
@cache.memoize_method @cache.memoize_method

View File

@@ -6,6 +6,7 @@ import inspect
import os import os
from parso.python import parse from parso.python import parse
from jedi import settings
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.cache import underscore_memoization from jedi.cache import underscore_memoization
from jedi.evaluate import imports from jedi.evaluate import imports
@@ -108,7 +109,8 @@ def _load_module(evaluator, path, python_object):
grammar=evaluator.grammar, grammar=evaluator.grammar,
path=path, path=path,
cache=True, cache=True,
diff_cache=True diff_cache=True,
cache_path=settings.cache_directory
).get_root_node() ).get_root_node()
python_module = inspect.getmodule(python_object) python_module = inspect.getmodule(python_object)

View File

@@ -471,7 +471,9 @@ def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=N
if path is not None and path.endswith(('.py', '.zip', '.egg')) \ if path is not None and path.endswith(('.py', '.zip', '.egg')) \
and dotted_path not in settings.auto_import_modules: and dotted_path not in settings.auto_import_modules:
module_node = parse(code=code, path=path, cache=True, diff_cache=True) module_node = parse(
code=code, path=path, cache=True, diff_cache=True,
cache_path=settings.cache_directory)
from jedi.evaluate.representation import ModuleContext from jedi.evaluate.representation import ModuleContext
return ModuleContext(evaluator, module_node, path=path) return ModuleContext(evaluator, module_node, path=path)

View File

@@ -7,10 +7,11 @@ from jedi._compatibility import exec_function, unicode
from parso.python import tree from parso.python import tree
from parso.python import parse from parso.python import parse
from jedi.evaluate.cache import memoize_default from jedi.evaluate.cache import memoize_default
from jedi import debug
from jedi import common
from jedi.evaluate.compiled import CompiledObject from jedi.evaluate.compiled import CompiledObject
from jedi.evaluate.context import ContextualizedNode from jedi.evaluate.context import ContextualizedNode
from jedi import settings
from jedi import debug
from jedi import common
def get_venv_path(venv): def get_venv_path(venv):
@@ -214,7 +215,8 @@ def _get_paths_from_buildout_script(evaluator, buildout_script_path):
module_node = parse( module_node = parse(
path=buildout_script_path, path=buildout_script_path,
grammar=evaluator.grammar, grammar=evaluator.grammar,
cache=True cache=True,
cache_path=settings.cache_directory
) )
except IOError: except IOError:
debug.warning('Error trying to read buildout_script: %s', buildout_script_path) debug.warning('Error trying to read buildout_script: %s', buildout_script_path)

View File

@@ -239,4 +239,3 @@ def get_parent_scope(node, include_flows=False):
break break
scope = scope.parent scope = scope.parent
return scope return scope