1
0
forked from VimPlug/jedi

Refactor Jedi so we use stub modules as much as possible

This commit is contained in:
Dave Halter
2019-05-01 00:52:02 +02:00
parent 3afcfccba8
commit 0e42df2da7
12 changed files with 125 additions and 86 deletions

View File

@@ -1,5 +1,4 @@
from jedi.plugins.base import BasePlugin
from jedi.evaluate.imports import JediImportError
class FlaskPlugin(BasePlugin):
@@ -8,21 +7,18 @@ class FlaskPlugin(BasePlugin):
Handle "magic" Flask extension imports:
``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
"""
def wrapper(evaluator, import_names, module_context, sys_path, load_stub):
def wrapper(evaluator, import_names, module_context, sys_path):
if len(import_names) == 3 and import_names[:2] == ('flask', 'ext'):
# New style.
ipath = (u'flask_' + import_names[2]),
try:
return callback(evaluator, ipath, None, sys_path, load_stub)
except JediImportError:
context_set = callback(evaluator, ipath, None, sys_path)
if not context_set:
context_set = callback(evaluator, (u'flaskext',), None, sys_path)
# If context_set has no content a JediImportError is raised
# which should be caught anyway by the caller.
return callback(
evaluator,
(u'flaskext', import_names[2]),
next(iter(context_set)),
sys_path
)
return callback(evaluator, import_names, module_context, sys_path, load_stub)
return callback(evaluator, import_names, module_context, sys_path)
return wrapper