diff --git a/jedi/parser/python/__init__.py b/jedi/parser/python/__init__.py index 9b7ca75f..3f86dfb5 100644 --- a/jedi/parser/python/__init__.py +++ b/jedi/parser/python/__init__.py @@ -3,6 +3,7 @@ Parsers for Python """ import os +from jedi import settings from jedi._compatibility import FileNotFoundError from jedi.parser.pgen2.pgen import generate_grammar from jedi.parser.python.parser import Parser, _remove_last_newline @@ -86,7 +87,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True, with open(path, 'rb') as f: code = source_to_unicode(f.read()) - if diff_cache: + if diff_cache and settings.fast_parser: try: module_cache_item = parser_cache[path] except KeyError: diff --git a/jedi/parser/python/diff.py b/jedi/parser/python/diff.py index 3da9809d..3d4715eb 100644 --- a/jedi/parser/python/diff.py +++ b/jedi/parser/python/diff.py @@ -9,35 +9,14 @@ import re import difflib from collections import namedtuple -from jedi._compatibility import use_metaclass -from jedi import settings from jedi.common import splitlines from jedi.parser.python.parser import Parser, _remove_last_newline from jedi.parser.python.tree import EndMarker -from jedi.parser.cache import parser_cache from jedi import debug from jedi.parser.tokenize import (generate_tokens, NEWLINE, TokenInfo, ENDMARKER, INDENT, DEDENT) -class CachedFastParser(type): - """ This is a metaclass for caching `FastParser`. """ - def __call__(self, grammar, source, module_path=None): - pi = parser_cache.get(module_path, None) - if pi is None or not settings.fast_parser: - return Parser(grammar, source, module_path) - - parser = pi.parser - d = DiffParser(parser) - new_lines = splitlines(source, keepends=True) - parser.module = parser._parsed = d.update(new_lines) - return parser - - -class FastParser(use_metaclass(CachedFastParser)): - pass - - def _get_last_line(node_or_leaf): last_leaf = node_or_leaf.get_last_leaf() if _ends_with_newline(last_leaf):