Move import logic around a bit

This commit is contained in:
Dave Halter
2018-07-23 03:54:10 +02:00
parent 7711167052
commit 8a9202135b
3 changed files with 152 additions and 106 deletions
+8
View File
@@ -11,3 +11,11 @@ class BasePlugin(object):
Decorates the execute(context, arguments) function.
"""
return callback
def import_module(callback):
"""
Decorates the
import_module(evaluator, import_path, sys_path, add_error_callback)
function.
"""
return callback
+33
View File
@@ -0,0 +1,33 @@
from jedi.plugins.base import BasePlugin
from jedi.evaluate.base_context import Context, ContextSet
class TypeshedPlugin(BasePlugin):
def foo():
return
class TypeshedProxy(object):
def __init__(self, parent_context, context, typeshed_context):
self.parent_context = parent_context
self._context = context
self._typeshed_context = typeshed_context
# We have to overwrite everything that has to do with trailers, name
# lookups and filters to make it possible to route name lookups towards
# compiled objects and the rest towards tree node contexts.
def py__getattribute__(self, *args, **kwargs):
context_results = self._context.py__getattribute__(
*args, **kwargs
)
typeshed_results = self._typeshed_context = py__getattribute__(
*args, **kwargs
)
print(context_results, typeshed_results)
return context_results
def __getattr__(self, name):
return getattr(self._context, name)
def __repr__(self):
return '<%s: %s>' % (type(self).__name__, self.access_handle.get_repr())