davidhalter / davidhalter/jedi-vim

Discovery of stubs in a different folder

Open
#1,078 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.3k
Forks
369
PR merge metrics
No merged PRs in 30d

Description

I'm having trouble with discovery of `.pyi` stub files that live in a different folder from the `.py` source file.

#### Here is an example that works as expected:
```commandline
.
├── code
│   ├── foo.py
│   └── foo.pyi
└── main.py
```
If I set the environment variable `PYTHONPATH=code` and if `main.py` contains the line `from foo import bar`, then `jedi#goto_stubs()` works as expected (it finds the definition of `bar` in `code/foo.pyi`).

#### Here is an example that is not working:
I am having problems when the file layout looks like this:
```commandline
.
├── code
│ └── foo.py
├── stubs
│ └── foo.pyi
└── main.py
```
In this situation, `jedi#goto_stubs()` does not work.
I have tried the following environment variable settings:
- `PYTHONPATH=code:stubs`
- `PYTHONPATH=code MYPYPATH=stubs`

I would expect that the `.pyi` file can be discovered as long as it is discoverable on `PYTHONPATH` or `MYPYPATH`, but this seems not to be the case.

Contributor guide

Open the contributing guide

Research direction

Reproduce the two layouts described with main.py, code/foo.py, and foo.pyi, using jedi#goto_stubs() and the listed PYTHONPATH or MYPYPATH settings. Compare the working same-folder case with the separate stubs folder, then confirm the issue is resolved when the .pyi definition is discovered from the configured paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, vim
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.