forked from VimPlug/jedi
Use a class stub class
This commit is contained in:
@@ -165,6 +165,12 @@ class StubName(TreeNameDefinition):
|
|||||||
c.parent_context,
|
c.parent_context,
|
||||||
c.tree_node,
|
c.tree_node,
|
||||||
)
|
)
|
||||||
|
elif isinstance(c, ClassContext):
|
||||||
|
yield ClassStubContext(
|
||||||
|
c.evaluator,
|
||||||
|
c.parent_context,
|
||||||
|
c.tree_node
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
@@ -176,7 +182,6 @@ class StubName(TreeNameDefinition):
|
|||||||
return ContextSet.from_iterable(iterate(contexts))
|
return ContextSet.from_iterable(iterate(contexts))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StubParserTreeFilter(ParserTreeFilter):
|
class StubParserTreeFilter(ParserTreeFilter):
|
||||||
name_class = StubName
|
name_class = StubName
|
||||||
|
|
||||||
|
|||||||
@@ -37,14 +37,20 @@ def test_get_stub_files():
|
|||||||
|
|
||||||
|
|
||||||
def test_function(Script):
|
def test_function(Script):
|
||||||
s = Script('import threading; threading.current_thread')
|
code = 'import threading; threading.current_thread'
|
||||||
def_, = s.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.FunctionStubContext), context
|
||||||
|
|
||||||
|
def_, = Script(code + '()').goto_definitions()
|
||||||
|
context = def_._name._context
|
||||||
|
assert isinstance(context, typeshed.ClassStubContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_class(Script):
|
def test_class(Script):
|
||||||
s = Script('import threading; threading.Lock')
|
def_, = Script('import threading; threading.Lock').goto_definitions()
|
||||||
|
context = def_._name._context
|
||||||
|
assert isinstance(context, typeshed.ClassStubContext), context
|
||||||
|
|
||||||
|
|
||||||
def test_instance(Script):
|
def test_instance(Script):
|
||||||
|
|||||||
Reference in New Issue
Block a user