forked from VimPlug/jedi
Disable some features for big annoying libraries like pandas, tensorflow, see #520
This commit is contained in:
@@ -24,7 +24,7 @@ from jedi.inference.cache import inference_state_method_cache
|
||||
from jedi.inference import imports
|
||||
from jedi.inference.arguments import TreeArguments
|
||||
from jedi.inference.param import get_executed_param_names
|
||||
from jedi.inference.helpers import is_stdlib_path
|
||||
from jedi.inference.helpers import is_stdlib_path, is_big_annoying_library
|
||||
from jedi.inference.utils import to_list
|
||||
from jedi.inference.value import instance
|
||||
from jedi.inference.base_value import ValueSet, NO_VALUES
|
||||
@@ -67,6 +67,9 @@ def dynamic_param_lookup(function_value, param_index):
|
||||
have to look for all calls to ``func`` to find out what ``foo`` possibly
|
||||
is.
|
||||
"""
|
||||
if is_big_annoying_library(function_value.parent_context):
|
||||
return NO_VALUES
|
||||
|
||||
funcdef = function_value.tree_node
|
||||
|
||||
if not settings.dynamic_params:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from jedi.parser_utils import get_flow_branch_keyword, is_scope, get_parent_scope
|
||||
from jedi.inference.recursion import execution_allowed
|
||||
from jedi.inference.helpers import is_big_annoying_library
|
||||
|
||||
|
||||
class Status(object):
|
||||
@@ -42,6 +43,9 @@ def _get_flow_scopes(node):
|
||||
|
||||
|
||||
def reachability_check(context, value_scope, node, origin_scope=None):
|
||||
if is_big_annoying_library(context):
|
||||
return UNSURE
|
||||
|
||||
first_flow_scope = get_parent_scope(node, include_flows=True)
|
||||
if origin_scope is not None:
|
||||
origin_flow_scopes = list(_get_flow_scopes(origin_scope))
|
||||
|
||||
@@ -261,3 +261,9 @@ def parse_dotted_names(nodes, is_import_from, until_node=None):
|
||||
|
||||
def values_from_qualified_names(inference_state, *names):
|
||||
return inference_state.import_module(names[:-1]).py__getattribute__(names[-1])
|
||||
|
||||
|
||||
def is_big_annoying_library(context):
|
||||
string_names = context.get_root_context().string_names
|
||||
# Pandas is huge, so just ignore it, because stuff makes everything slow.
|
||||
return string_names[0] in ('pandas', 'numpy', 'tensorflow', 'matplotlib')
|
||||
|
||||
@@ -6,7 +6,7 @@ from jedi import debug
|
||||
from jedi import settings
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference.compiled.value import CompiledObjectFilter
|
||||
from jedi.inference.helpers import values_from_qualified_names
|
||||
from jedi.inference.helpers import values_from_qualified_names, is_big_annoying_library
|
||||
from jedi.inference.filters import AbstractFilter, AnonymousFunctionExecutionFilter
|
||||
from jedi.inference.names import ValueName, TreeNameDefinition, ParamName, \
|
||||
NameWrapper
|
||||
@@ -237,6 +237,8 @@ class _BaseTreeInstance(AbstractInstanceValue):
|
||||
# We are inversing this, because a hand-crafted `__getattribute__`
|
||||
# could still call another hand-crafted `__getattr__`, but not the
|
||||
# other way around.
|
||||
if is_big_annoying_library(self.parent_context):
|
||||
return NO_VALUES
|
||||
names = (self.get_function_slot_names(u'__getattr__')
|
||||
or self.get_function_slot_names(u'__getattribute__'))
|
||||
return self.execute_function_slots(names, name)
|
||||
|
||||
Reference in New Issue
Block a user