Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When in __init__, a module in current directory isn't found #956

Closed
tony opened this issue Aug 19, 2017 · 1 comment
Closed

When in __init__, a module in current directory isn't found #956

tony opened this issue Aug 19, 2017 · 1 comment
Labels

Comments

@tony
Copy link

tony commented Aug 19, 2017

with jedi/vim-jedi,

to recreate, clone sphinx

git clone https://github.com/sphinx-doc/sphinx

Try to goto make_mode from sphinx/__init__.py:

https://github.com/sphinx-doc/sphinx/blob/774408347de2246d4f50282a58e81d8ccaf6bc3e/sphinx/__init__.py#L119

what jedi does: jumps to the top of __init__

what it should do, check for modules sphinx, not just current file, because there is a sphinx/make_mode.py: https://github.com/sphinx-doc/sphinx/blob/5ab26798d226d0e342c63409a7299c5934c704fc/sphinx/make_mode.py#L315

:Jedi
JediClearCache  JediDebugInfo
#### Jedi-vim debug information
Using Python version: 3
 - sys.version: `3.6.2 (default, Jul 17 2017, 16:44:45), [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]`
 - site module: `/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py`
Jedi path: `/Users/me/.vim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.10.2
 - sys_path:
    - `/Users/me/.dot-config/.vim/plugged/python-mode/pymode/libs`
    - `/Users/me/.dot-config/.vim/plugged/python-mode`
    - `/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python36.zip`
    - `/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6`
    - `/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload`
    - `/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages`
    - `/usr/local/Cellar/numpy/1.13.1_1/libexec/nose/lib/python3.6/site-packages`
    - `_vim_path_`
    - `/Users/me/.dot-config/.vim/plugged/riv.vim/autoload/riv/`
 - jedi-vim git version: 0c6a2b7
 - jedi git submodule status:  5427b02712828b2875d35b5ee1c8b5e58f820537 pythonx/jedi (v0.10.2)

##### Settings
g:jedi#use_splits_not_buffers = 'right' (default: 1)
g:jedi#documentation_command = '<leader>h' (default: 'K')
g:jedi#usages_command = '<leader>u' (default: '<leader>n')
g:jedi#completions_command = '<C-N>' (default: '<C-Space>')
g:jedi#popup_on_dot = 1 (default: 0)
g:jedi#auto_vim_configuration = 0 (default: 1)
g:jedi#smart_auto_mappings = 0 (default: 1)
g:jedi#show_call_signatures = 2 (default: 1)
g:jedi#completions_enabled = 0 (default: 1)

  omnifunc=jedi#completions
        Last set from ~/.dot-config/.vim/plugins.settings/jedi.vim
  completeopt=menu
        Last set from ~/.dot-config/.vim/plugins.settings/neocomplete.vim
@davidhalter
Copy link
Owner

Hi Toni

You're bringing up a good point. I'm not sure if it's easy to solve in the API. I think in the internal API it's already solved.

>>> import jedi
>>> x, = jedi.Script(path='sphinx/__init__.py', line=119).goto_assignments()
>>> x
<Definition module make_mode>
>>> x.module_path
'/home/dave/source/python/sphinx/sphinx/__init__.py'
>>> x._name
<SubModuleName: make_mode@(1, 0)>
>>> y, = x._name.infer()
>>> y
<ModuleContext: make_mode@2-326>
>>> y.py__file__()
'/home/dave/source/python/sphinx/sphinx/make_mode.py'

As you can above the module_path points to the current file. This is not necessarily wrong if you know that Python defines those names in the current module (which is unfortunate). You can also see that this is being represented as a SubModuleName above. If you then infer that name you can find the actual module.

I guess we probably just have to handle SubModuleName separately.

~ Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants