forked from VimPlug/jedi
Ignore stdlib paths for dynamic param inference.
This commit is contained in:
@@ -206,7 +206,7 @@ class CompiledObject(Context):
|
||||
# Get rid of side effects, we won't call custom `__getitem__`s.
|
||||
return
|
||||
|
||||
for part in self.obj:
|
||||
for i, part in enumerate(self.obj):
|
||||
yield LazyKnownContext(create(self.evaluator, part))
|
||||
|
||||
def py__name__(self):
|
||||
|
||||
@@ -23,6 +23,7 @@ from jedi import debug
|
||||
from jedi.evaluate.cache import evaluator_function_cache
|
||||
from jedi.evaluate import imports
|
||||
from jedi.evaluate.param import TreeArguments, create_default_param
|
||||
from jedi.evaluate.helpers import is_stdlib_path
|
||||
from jedi.common import to_list, unite
|
||||
from jedi.parser_utils import get_parent_scope
|
||||
|
||||
@@ -67,11 +68,20 @@ def search_params(evaluator, execution_context, funcdef):
|
||||
is.
|
||||
"""
|
||||
if not settings.dynamic_params:
|
||||
return set()
|
||||
return []
|
||||
|
||||
evaluator.dynamic_params_depth += 1
|
||||
try:
|
||||
path = execution_context.get_root_context().py__file__()
|
||||
if path is not None and is_stdlib_path(path):
|
||||
# We don't want to search for usages in the stdlib. Usually people
|
||||
# don't work with it (except if you are a core maintainer, sorry).
|
||||
# This makes everything slower. Just disable it and run the tests,
|
||||
# you will see the slowdown, especially in 3.6.
|
||||
return []
|
||||
|
||||
debug.dbg('Dynamic param search in %s.', funcdef.name.value, color='MAGENTA')
|
||||
|
||||
module_context = execution_context.get_root_context()
|
||||
function_executions = _search_function_executions(
|
||||
evaluator,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import copy
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
from itertools import chain
|
||||
from contextlib import contextmanager
|
||||
|
||||
@@ -6,6 +9,14 @@ from parso.python import tree
|
||||
from jedi.parser_utils import get_parent_scope
|
||||
|
||||
|
||||
def is_stdlib_path(path):
|
||||
# Python standard library paths look like this:
|
||||
# /usr/lib/python3.5/...
|
||||
# TODO The implementation below is probably incorrect and not complete.
|
||||
base_path = os.path.join(sys.prefix, 'lib', 'python')
|
||||
return bool(re.match(re.escape(base_path) + '\d.\d', path))
|
||||
|
||||
|
||||
def deep_ast_copy(obj):
|
||||
"""
|
||||
Much, much faster than copy.deepcopy, but just for parser tree nodes.
|
||||
|
||||
@@ -407,6 +407,9 @@ class ParamArguments(object):
|
||||
continue
|
||||
yield None, self.LazyParamContext(p)
|
||||
|
||||
def get_calling_nodes(self):
|
||||
return []
|
||||
|
||||
|
||||
class InstanceVarArgs(object):
|
||||
def __init__(self, execution_context, funcdef, var_args):
|
||||
|
||||
@@ -70,6 +70,9 @@ class AbstractArguments():
|
||||
types = lazy_context.infer()
|
||||
try_iter_content(types)
|
||||
|
||||
def get_calling_nodes(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class TreeArguments(AbstractArguments):
|
||||
def __init__(self, evaluator, context, argument_node, trailer=None):
|
||||
|
||||
Reference in New Issue
Block a user