From 81e9403aefc194874509857370864db5de3562b0 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 17 Dec 2016 18:00:54 +0100 Subject: [PATCH] Delete more unused code. --- jedi/cache.py | 8 -------- jedi/evaluate/__init__.py | 23 ++--------------------- jedi/evaluate/imports.py | 30 ------------------------------ jedi/evaluate/instance.py | 12 ------------ jedi/evaluate/representation.py | 5 +---- 5 files changed, 3 insertions(+), 75 deletions(-) diff --git a/jedi/cache.py b/jedi/cache.py index 81d82375..6aaf2779 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -92,14 +92,6 @@ def memoize_method(method): return wrapper -def cache_star_import(func): - @time_cache("star_import_cache_validity") - def wrapper(self): - yield self.base # The cache key - yield func(self) - return wrapper - - def _invalidate_star_import_cache_module(module, only_main=False): """ Important if some new modules are being reparsed """ try: diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index 85f60df1..0ca4e937 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -324,13 +324,6 @@ class Evaluator(object): if isinstance(atom, tree.Name): # This is the first global lookup. stmt = atom.get_definition() - #if isinstance(context, er.FunctionExecution): - ## Adjust scope: If the name is not in the suite, it's a param - ## default or annotation and will be resolved as part of the - ## parent scope. - #colon = scope.children.index(':') - #if atom.start_pos < scope.children[colon + 1].start_pos: - ##scope = scope.get_parent_scope() if isinstance(stmt, tree.CompFor): stmt = stmt.get_parent_until((tree.ClassOrFunc, tree.ExprStmt)) if stmt.type != 'expr_stmt': @@ -355,8 +348,8 @@ class Evaluator(object): return types # Parentheses without commas are not tuples. elif c[0] == '(' and not len(c) == 2 \ - and not(tree.is_node(c[1], 'testlist_comp') - and len(c[1].children) > 1): + and not(tree.is_node(c[1], 'testlist_comp') and + len(c[1].children) > 1): return self.eval_element(context, c[1]) try: @@ -520,18 +513,6 @@ class Evaluator(object): search_global=True, is_goto=True ) - def wrap(self, element, parent_context): - raise DeprecationWarning - if element.type == 'classdef': - return er.ClassContext(self, element, parent_context) - elif element.type == 'lambda': - return er.LambdaWrapper(self, element) - elif element.type == 'file_input': - return er.ModuleContext(self, element) - else: - raise DeprecationWarning - return element - def create_context(self, base_context, node, node_is_context=False): def parent_scope(node): while True: diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index 979ebd79..fd6028d1 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -31,32 +31,6 @@ from jedi.evaluate.cache import memoize_default from jedi.evaluate.filters import AbstractNameDefinition -def completion_names(evaluator, imp, pos): - name = imp.name_for_position(pos) - module = evaluator.wrap(imp.get_parent_until()) - if name is None: - level = 0 - for node in imp.children: - if node.end_pos <= pos: - if node in ('.', '...'): - level += len(node.value) - import_path = [] - else: - # Completion on an existing name. - - # The import path needs to be reduced by one, because we're completing. - import_path = imp.path_for_name(name)[:-1] - level = imp.level - - importer = Importer(evaluator, tuple(import_path), module, level) - if isinstance(imp, tree.ImportFrom): - c = imp.children - only_modules = c[c.index('import')].start_pos >= pos - else: - only_modules = True - return importer.completion_names(evaluator, only_modules) - - # This memoization is needed, because otherwise we will infinitely loop on # certain imports. @memoize_default(default=set()) @@ -385,9 +359,6 @@ class Importer(object): def _generate_name(self, name, in_module=None): # Create a pseudo import to be able to follow them. if in_module is None: - #imp = helpers.FakeImport(name, parent=self.module_context) - #name.parent = imp - #return name return ImportName(self.module_context, name) return SubModuleName(in_module, name) @@ -413,7 +384,6 @@ class Importer(object): :param only_modules: Indicates wheter it's possible to import a definition that is not defined in a module. """ - from jedi.evaluate import finder from jedi.evaluate.representation import ModuleContext names = [] if self.import_path: diff --git a/jedi/evaluate/instance.py b/jedi/evaluate/instance.py index f0fbc051..4db6d63c 100644 --- a/jedi/evaluate/instance.py +++ b/jedi/evaluate/instance.py @@ -367,18 +367,6 @@ class SelfNameFilter(InstanceClassFilter): and trailer.children[0] == '.': if name.is_definition() and self._access_possible(name): yield name - continue - - - - - - init_execution = self.context.get_init_function() - # Hopefully we can somehow change this. - if init_execution is not None and \ - init_execution.start_pos < name.start_pos < init_execution.end_pos: - name = init_execution.name_for_position(name.start_pos) - yield name def _check_flows(self, names): return names diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 316b0be7..ff200fa2 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -41,14 +41,12 @@ import pkgutil import imp import re -from jedi._compatibility import use_metaclass, unicode, Python3Method +from jedi._compatibility import use_metaclass from jedi.parser import tree from jedi import debug from jedi import common -from jedi.cache import cache_star_import from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT from jedi.evaluate import compiled -from jedi.evaluate.compiled import mixed from jedi.evaluate import recursion from jedi.evaluate import iterable from jedi.evaluate import docstrings @@ -444,7 +442,6 @@ class ModuleContext(use_metaclass(CachedMetaClass, context.TreeContext)): # I'm not sure if the star import cache is really that effective anymore # with all the other really fast import caches. Recheck. Also we would need # to push the star imports into Evaluator.modules, if we reenable this. - #@cache_star_import @memoize_default([]) def star_imports(self): modules = []