1
0
forked from VimPlug/jedi

Add the flask plugin and move the import hacks there

This commit is contained in:
Dave Halter
2018-07-23 04:04:07 +02:00
parent 8a9202135b
commit 27ab4ba339
5 changed files with 38 additions and 13 deletions

View File

@@ -123,6 +123,10 @@ class Evaluator(object):
from jedi.plugins import plugin_manager
plugin_callbacks = plugin_manager.get_callbacks(self)
self.execute = plugin_callbacks.decorate('execute', callback=execute)
self.import_module = plugin_callbacks.decorate(
'import_module',
callback=imports.import_module
)
@property
@evaluator_function_cache()

View File

@@ -282,7 +282,7 @@ class Importer(object):
if not self.import_path:
return NO_CONTEXTS
return import_module(
return self._evaluator.import_module(
self._evaluator,
self.import_path,
self.sys_path_with_modifications(),
@@ -387,16 +387,6 @@ def import_module(evaluator, import_path, sys_path, add_error_callback):
for i in import_path
]
if len(import_path) > 2 and import_parts[:2] == ['flask', 'ext']:
# New style.
ipath = ('flask_' + str(import_parts[2]),) + import_path[3:]
modules = import_module(evaluator, ipath, sys_path, add_error_callback)
if modules:
return modules
else:
# Old style
return import_module(evaluator, ('flaskext',) + import_path[2:], sys_path, add_error_callback)
if import_parts[0] in settings.auto_import_modules:
module = _load_module(
evaluator,
@@ -414,7 +404,7 @@ def import_module(evaluator, import_path, sys_path, add_error_callback):
if len(import_path) > 1:
# This is a recursive way of importing that works great with
# the module cache.
bases = import_module(evaluator, import_path[:-1], sys_path, add_error_callback)
bases = evaluator.import_module(evaluator, import_path[:-1], sys_path, add_error_callback)
if not bases:
return NO_CONTEXTS
# We can take the first element, because only the os special