Open sohaiberrabii opened 4 months ago
What's your directory structure? I would guess that this is a won't fix from our side, because the import logic probably checks sys.modules
first, which loads some modules first.
IMO it's a very very bad idea anyway to overwrite top level builtins. It should be fine to use something like from jedi import _ast
though.
This came up when I tried using jedi-vim's goto on a symbol defined in the module. The module itself is from an editable installed package.
It doesn't overwrite the builtin, only shares the name. It's not a top-level module and internally the package is using relative import from ._ast import *
. In the following code, the goto-command of jedi-vim will fail for both even though Foo
is not defined in a builtin.
from localpackage._ast import Foo
from _ast import AST # builtin
Its a pretty rare use case, I only opened the issue in case someone else encounters it.
When a library uses module names that conflicts with builtins, such as
_ast.py
, the import logic in https://github.com/davidhalter/jedi/blob/master/jedi/inference/compiled/subprocess/functions.py#L139 ends up usingimportlib.machinery.BuiltinImporter
as it appears beforeimportlib.machinery.PathFinder
insys.meta_path
.