forked from VimPlug/jedi
Eliminate more actual appearances
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user