forked from VimPlug/jedi
Rename some stub classes
This commit is contained in:
@@ -82,7 +82,7 @@ def _merge_modules(context_set, stub_context):
|
|||||||
for context in context_set:
|
for context in context_set:
|
||||||
# TODO what about compiled?
|
# TODO what about compiled?
|
||||||
if isinstance(context, ModuleContext):
|
if isinstance(context, ModuleContext):
|
||||||
yield ModuleStubContext(
|
yield StubModuleContext(
|
||||||
context.evaluator,
|
context.evaluator,
|
||||||
stub_context,
|
stub_context,
|
||||||
context.tree_node,
|
context.tree_node,
|
||||||
@@ -123,7 +123,7 @@ class TypeshedPlugin(BasePlugin):
|
|||||||
evaluator,
|
evaluator,
|
||||||
import_names,
|
import_names,
|
||||||
parent_module_context.actual_context # noqa
|
parent_module_context.actual_context # noqa
|
||||||
if isinstance(parent_module_context, ModuleStubContext)
|
if isinstance(parent_module_context, StubModuleContext)
|
||||||
else parent_module_context,
|
else parent_module_context,
|
||||||
sys_path
|
sys_path
|
||||||
)
|
)
|
||||||
@@ -131,7 +131,7 @@ class TypeshedPlugin(BasePlugin):
|
|||||||
map_ = None
|
map_ = None
|
||||||
if len(import_names) == 1 and import_name != 'typing':
|
if len(import_names) == 1 and import_name != 'typing':
|
||||||
map_ = self._cache_stub_file_map(evaluator.grammar.version_info)
|
map_ = self._cache_stub_file_map(evaluator.grammar.version_info)
|
||||||
elif isinstance(parent_module_context, ModuleStubContext):
|
elif isinstance(parent_module_context, StubModuleContext):
|
||||||
map_ = _merge_create_stub_map(parent_module_context.py__path__())
|
map_ = _merge_create_stub_map(parent_module_context.py__path__())
|
||||||
|
|
||||||
if map_ is not None:
|
if map_ is not None:
|
||||||
@@ -194,7 +194,7 @@ class StubName(TreeNameDefinition):
|
|||||||
)
|
)
|
||||||
elif isinstance(stub_context, ClassContext) \
|
elif isinstance(stub_context, ClassContext) \
|
||||||
and isinstance(actual_context, ClassContext):
|
and isinstance(actual_context, ClassContext):
|
||||||
yield ClassStubContext(
|
yield StubClassContext(
|
||||||
actual_context.evaluator,
|
actual_context.evaluator,
|
||||||
stub_context,
|
stub_context,
|
||||||
actual_context.parent_context,
|
actual_context.parent_context,
|
||||||
@@ -281,11 +281,11 @@ class _StubContextFilterMixin(_MixedStubContextMixin):
|
|||||||
yield f
|
yield f
|
||||||
|
|
||||||
|
|
||||||
class ModuleStubContext(_StubContextFilterMixin, ModuleContext):
|
class StubModuleContext(_StubContextFilterMixin, ModuleContext):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ClassStubContext(_StubContextFilterMixin, ClassContext):
|
class StubClassContext(_StubContextFilterMixin, ClassContext):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,31 +41,31 @@ def test_function(Script):
|
|||||||
code = 'import threading; threading.current_thread'
|
code = 'import threading; threading.current_thread'
|
||||||
def_, = Script(code).goto_definitions()
|
def_, = Script(code).goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, typeshed.FunctionStubContext), context
|
assert isinstance(context, typeshed.StubFunctionContext), context
|
||||||
|
|
||||||
def_, = Script(code + '()').goto_definitions()
|
def_, = Script(code + '()').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, TreeInstance)
|
assert isinstance(context, TreeInstance)
|
||||||
assert isinstance(context.class_context, typeshed.ClassStubContext), context
|
assert isinstance(context.class_context, typeshed.StubClassContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_class(Script):
|
def test_class(Script):
|
||||||
def_, = Script('import threading; threading.Thread').goto_definitions()
|
def_, = Script('import threading; threading.Thread').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, typeshed.ClassStubContext), context
|
assert isinstance(context, typeshed.StubClassContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_instance(Script):
|
def test_instance(Script):
|
||||||
def_, = Script('import threading; threading.Thread()').goto_definitions()
|
def_, = Script('import threading; threading.Thread()').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, TreeInstance)
|
assert isinstance(context, TreeInstance)
|
||||||
assert isinstance(context.class_context, typeshed.ClassStubContext), context
|
assert isinstance(context.class_context, typeshed.StubClassContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_class_function(Script):
|
def test_class_function(Script):
|
||||||
def_, = Script('import threading; threading.Thread.getName').goto_definitions()
|
def_, = Script('import threading; threading.Thread.getName').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, typeshed.FunctionStubContext), context
|
assert isinstance(context, typeshed.StubFunctionContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_method(Script):
|
def test_method(Script):
|
||||||
@@ -73,7 +73,7 @@ def test_method(Script):
|
|||||||
def_, = Script(code).goto_definitions()
|
def_, = Script(code).goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, BoundMethod), context
|
assert isinstance(context, BoundMethod), context
|
||||||
assert isinstance(context._function, typeshed.FunctionStubContext), context
|
assert isinstance(context._function, typeshed.StubFunctionContext), context
|
||||||
|
|
||||||
def_, = Script(code + '()').goto_definitions()
|
def_, = Script(code + '()').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
|
|||||||
Reference in New Issue
Block a user