forked from VimPlug/jedi
Fix a few of the issues with compiled classes and typeshed and docs
This commit is contained in:
@@ -16,7 +16,7 @@ from jedi.evaluate.context.function import FunctionMixin
|
||||
from jedi.evaluate.context.klass import ClassMixin
|
||||
from jedi.evaluate.context.typing import TypingModuleFilterWrapper, \
|
||||
TypingModuleName
|
||||
from jedi.evaluate.compiled.context import CompiledName
|
||||
from jedi.evaluate.compiled.context import CompiledName, CompiledObject
|
||||
from jedi.evaluate.utils import to_list
|
||||
|
||||
|
||||
@@ -212,6 +212,16 @@ class NameWithStubMixin(object):
|
||||
actual_context,
|
||||
stub_context,
|
||||
)
|
||||
elif isinstance(stub_context, VersionInfo):
|
||||
# TODO needed?
|
||||
yield stub_context
|
||||
elif isinstance(actual_context, CompiledObject):
|
||||
if actual_context.is_class():
|
||||
yield CompiledStubClass.create_cached(
|
||||
stub_context.evaluator, stub_context, actual_context)
|
||||
else:
|
||||
yield _StubContextWithCompiled.create_cached(
|
||||
stub_context.evaluator, stub_context, actual_context)
|
||||
else:
|
||||
yield stub_context
|
||||
|
||||
@@ -467,11 +477,7 @@ class StubOnlyClass(_StubOnlyContext, ClassMixin, ContextWrapper):
|
||||
pass
|
||||
|
||||
|
||||
class _StubContextWithCompiled(ContextWrapper):
|
||||
def __init__(self, stub_context, compiled_context):
|
||||
super(_StubContextWithCompiled, self).__init__(stub_context)
|
||||
self.compiled_context = compiled_context
|
||||
|
||||
class _StubContextMixin(object):
|
||||
def py__doc__(self, include_call_signature=False):
|
||||
doc = self.compiled_context.py__doc__()
|
||||
if include_call_signature:
|
||||
@@ -481,6 +487,16 @@ class _StubContextWithCompiled(ContextWrapper):
|
||||
return doc
|
||||
|
||||
|
||||
class _StubContextWithCompiled(_StubContextMixin, ContextWrapper):
|
||||
def __init__(self, stub_context, compiled_context):
|
||||
super(_StubContextWithCompiled, self).__init__(stub_context)
|
||||
self.compiled_context = compiled_context
|
||||
|
||||
|
||||
class CompiledStubClass(_StubContextWithCompiled, ClassMixin):
|
||||
pass
|
||||
|
||||
|
||||
class TypingModuleWrapper(StubOnlyModuleContext):
|
||||
# TODO should use this instead of the isinstance check
|
||||
def get_filterss(self, *args, **kwargs):
|
||||
|
||||
@@ -14,8 +14,9 @@ def test_simple(evaluator):
|
||||
|
||||
def test_builtin_loading(evaluator):
|
||||
string, = evaluator.builtins_module.py__getattribute__(u'str')
|
||||
from_name = compiled.context.create_from_name(evaluator, string, u'__init__')
|
||||
from_name, = string.py__getattribute__('__init__')
|
||||
assert from_name.tree_node
|
||||
assert from_name.py__doc__()
|
||||
|
||||
|
||||
def test_fake_docstr(evaluator):
|
||||
@@ -41,7 +42,7 @@ def test_doc(evaluator):
|
||||
"""
|
||||
str_ = compiled.create_simple_object(evaluator, u'')
|
||||
# Equals `''.__getnewargs__`
|
||||
obj = compiled.create_from_name(evaluator, str_, u'__getnewargs__')
|
||||
obj, = str_.py__getattribute__('__getnewargs__')
|
||||
assert obj.py__doc__() == ''
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user