diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index 62643771..5592403e 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -511,7 +511,9 @@ def remove_star_imports(evaluator, scope, ignored_modules=()): def _load_module(path=None, source=None, name=None, sys_path=None): def load(source): - if path is not None and path.endswith('.py'): + dotted_path = path and _reverse_fs_path(path, sys_path) + if path is not None and path.endswith('.py') \ + and not dotted_path in settings.auto_import_modules: if source is None: with open(path, 'rb') as f: source = f.read() diff --git a/jedi/settings.py b/jedi/settings.py index 54e801e9..a0839e99 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -42,6 +42,7 @@ Dynamic stuff .. autodata:: dynamic_params .. autodata:: dynamic_params_for_other_modules .. autodata:: additional_dynamic_modules +.. autodata:: auto_import_modules .. _settings-recursion: @@ -179,6 +180,13 @@ dynamic_flow_information = True Check for `isinstance` and other information to infer a type. """ +auto_import_modules = ['hashlib'] +""" +Modules that are not analyzed but imported, although they contain Python code. +This improves autocompletion for libraries that use ``setattr`` or +``globals()`` modifications a lot. +""" + # ---------------- # recursions # ----------------