forked from VimPlug/jedi
Eliminate more actual appearances
This commit is contained in:
@@ -18,7 +18,7 @@ from jedi.evaluate.imports import ImportName
|
||||
from jedi.evaluate.context import FunctionExecutionContext
|
||||
from jedi.evaluate.gradual.typeshed import StubModuleContext
|
||||
from jedi.evaluate.gradual.conversion import convert_names, \
|
||||
stub_to_actual_context_set
|
||||
stub_to_python_context_set
|
||||
from jedi.api.keywords import KeywordName
|
||||
|
||||
|
||||
@@ -704,7 +704,7 @@ class _Help(object):
|
||||
if not raw:
|
||||
signature_text = _format_signatures(context)
|
||||
if not doc and context.is_stub():
|
||||
for c in stub_to_actual_context_set(context):
|
||||
for c in stub_to_python_context_set(context):
|
||||
doc = c.py__doc__()
|
||||
if doc:
|
||||
break
|
||||
|
||||
@@ -11,7 +11,7 @@ from jedi.evaluate import imports
|
||||
from jedi.api import keywords
|
||||
from jedi.evaluate.helpers import evaluate_call_of_leaf, parse_dotted_names
|
||||
from jedi.evaluate.filters import get_global_filters
|
||||
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
|
||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
||||
from jedi.parser_utils import get_statement_of_position
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ class Completion:
|
||||
if not context.is_stub():
|
||||
continue
|
||||
|
||||
actual_contexts = stub_to_actual_context_set(context, ignore_compiled=True)
|
||||
actual_contexts = stub_to_python_context_set(context, ignore_compiled=True)
|
||||
for c in actual_contexts:
|
||||
for filter in c.get_filters(
|
||||
search_global=False,
|
||||
|
||||
@@ -29,7 +29,7 @@ from jedi.evaluate.filters import get_global_filters
|
||||
from jedi.evaluate.names import TreeNameDefinition
|
||||
from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS
|
||||
from jedi.parser_utils import is_scope, get_parent_scope
|
||||
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
|
||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
||||
|
||||
|
||||
class NameFinder(object):
|
||||
@@ -123,7 +123,7 @@ class NameFinder(object):
|
||||
yield f
|
||||
# This covers the case where a stub files are incomplete.
|
||||
if self._context.is_stub():
|
||||
contexts = stub_to_actual_context_set(self._context, ignore_compiled=True)
|
||||
contexts = stub_to_python_context_set(self._context, ignore_compiled=True)
|
||||
for c in contexts:
|
||||
for f in c.get_filters():
|
||||
yield f
|
||||
|
||||
@@ -5,7 +5,7 @@ from jedi.evaluate.utils import to_list
|
||||
from jedi.evaluate.gradual.stub_context import StubModuleContext
|
||||
|
||||
|
||||
def stub_to_actual_context_set(stub_context, ignore_compiled=False):
|
||||
def stub_to_python_context_set(stub_context, ignore_compiled=False):
|
||||
stub_module = stub_context.get_root_context()
|
||||
if not stub_module.is_stub():
|
||||
return ContextSet([stub_context])
|
||||
@@ -49,16 +49,6 @@ def _infer_from_stub(stub_module, qualified_names, ignore_compiled):
|
||||
return non_stubs
|
||||
|
||||
|
||||
def try_stubs_to_actual_context_set(stub_contexts, prefer_stub_to_compiled=False):
|
||||
contexts = ContextSet.from_sets(
|
||||
stub_to_actual_context_set(stub_context, ignore_compiled=prefer_stub_to_compiled)
|
||||
or ContextSet([stub_context])
|
||||
for stub_context in stub_contexts
|
||||
)
|
||||
debug.dbg('Stubs to actual: %s to %s', stub_contexts, contexts)
|
||||
return contexts
|
||||
|
||||
|
||||
@to_list
|
||||
def _try_stub_to_python_names(names, prefer_stub_to_compiled=False):
|
||||
for name in names:
|
||||
@@ -144,6 +134,7 @@ def convert_names(names, only_stubs, prefer_stubs):
|
||||
return _try_stub_to_python_names(names, prefer_stub_to_compiled=True)
|
||||
|
||||
|
||||
# TODO merge with _python_to_stub_names?
|
||||
def to_stub(context):
|
||||
if context.is_stub():
|
||||
return ContextSet([context])
|
||||
|
||||
@@ -356,9 +356,9 @@ class Importer(object):
|
||||
names += context.sub_modules_dict().values()
|
||||
|
||||
if not only_modules:
|
||||
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
|
||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
||||
both_contexts = ContextSet.from_sets(
|
||||
stub_to_actual_context_set(context, ignore_compiled=True)
|
||||
stub_to_python_context_set(context, ignore_compiled=True)
|
||||
for context in contexts
|
||||
if context.is_stub()
|
||||
) | contexts
|
||||
|
||||
15
test/run.py
15
test/run.py
@@ -126,7 +126,8 @@ from jedi.api.classes import Definition
|
||||
from jedi.api.completion import get_user_scope
|
||||
from jedi import parser_utils
|
||||
from jedi.api.environment import get_default_environment, get_system_environment
|
||||
from jedi.evaluate.gradual.conversion import try_stubs_to_actual_context_set
|
||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
||||
from jedi.evaluate.base_context import ContextSet
|
||||
|
||||
|
||||
TEST_COMPLETIONS = 0
|
||||
@@ -138,6 +139,16 @@ TEST_USAGES = 3
|
||||
grammar36 = parso.load_grammar(version='3.6')
|
||||
|
||||
|
||||
def try_stubs_to_python_context_set(stub_contexts, prefer_stub_to_compiled=False):
|
||||
contexts = ContextSet.from_sets(
|
||||
stub_to_python_context_set(stub_context, ignore_compiled=prefer_stub_to_compiled)
|
||||
or ContextSet([stub_context])
|
||||
for stub_context in stub_contexts
|
||||
)
|
||||
debug.dbg('Stubs to actual: %s to %s', stub_contexts, contexts)
|
||||
return contexts
|
||||
|
||||
|
||||
class IntegrationTestCase(object):
|
||||
def __init__(self, test_type, correct, line_nr, column, start, line,
|
||||
path=None, skip_version_info=None):
|
||||
@@ -231,7 +242,7 @@ class IntegrationTestCase(object):
|
||||
if user_context.api_type == 'function':
|
||||
user_context = user_context.get_function_execution()
|
||||
element.parent = user_context.tree_node
|
||||
results = try_stubs_to_actual_context_set(
|
||||
results = try_stubs_to_python_context_set(
|
||||
evaluator.eval_element(user_context, element),
|
||||
prefer_stub_to_compiled=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user