coc-pyright: reportMissingModuleSource using poetv + pyenv + poetry + mypy
I’m getting errors that I assume the plugin can’t find my virtualenv created by poetry.
Related shell configuration
# ~/.config/fish/config.fish
pyenv init - | source
which python3 | read -l answer
set -gx PYTHONPATH "$answer/site-packages" $PYTHONPATH
set -gx PYENV_ROOT $HOME/.pyenv
set -gx PIPENV_PYTHON "$PYENV_ROOT/shims/python"
# :CocInfo
## versions
vim version: VIM - Vi IMproved 8.2 8022450
node version: v12.14.1
coc.nvim version: 0.0.80-6e5a2aaeb5
vim src/file.py

:PoetvActivate
:call CocAction('reloadExtension', 'coc-pyright') I guess this is needed?

Doesn’t seem to work? (Also note my statusline’s backend-dmp... which denotes poetv has activated the environment)
Packages:
Click to expand
:!pip list
Package Version
------------------------- ------------
aiofiles 0.6.0
aiohttp 3.7.3
async-timeout 3.0.1
asyncio 3.4.3
attrs 20.3.0
boto3 1.16.24
botocore 1.19.24
cachetools 4.1.1
certifi 2020.11.8
chardet 3.0.4
h11 0.9.0
httpcore 0.11.1
httptools 0.1.1
httpx 0.15.4
idna 2.10
jmespath 0.10.0
multidict 5.0.0
mypy 0.800
mypy-boto3-secretsmanager 1.17.9.0
mypy-extensions 0.4.3
pip 19.2.3
python-dateutil 2.8.1
requests 2.25.0
rfc3986 1.4.0
s3transfer 0.3.3
sanic 20.9.1
Sanic-Cors 0.10.0.post3
Sanic-Plugins-Framework 0.9.4.post1
sentry-sdk 0.19.4
setuptools 41.2.0
six 1.15.0
sniffio 1.2.0
typed-ast 1.4.2
typing-extensions 3.7.4.3
ujson 4.0.1
urllib3 1.26.2
uvloop 0.14.0
websockets 8.1
yarl 1.6.3
the reverse order doesn’t work either: vim, :PoetvActivate, :e src/file.py.
However, poetry shell, vim src/file.py seems to work. What could be the issue here?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (10 by maintainers)
Is there any change in behavior if I start vim in the project root? Is the project root in this case the “backend” directory?
The information in this wiki may be helpful to ensure that project root (workspaceFolders) are detected properly. https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders
For reference, this is how I set it up when the file type is python.
As a side note, by default, the directory where .git is located may be detected as the project root.
@yaegassy Boom! There it is.
We use the
umbrelladirectory as an “umbrella”-directory for all of our projects at my work. So it has a.gitfolder.Perhaps Coc detects that it’s the workspace folder while it’s incorrect.
I added your snippet into my vimrc and voila!
For future readers, make sure to set
b:coc_root_patterns!@Lilja coc-pyright v1.1.116 will log what’s python is using in
:CocCommand workspace.showOutput- Pyright/coc-pyright-formatting/coc-pyright-linting.coc-pyright doesn’t care
PoetvActivate. The problem is when you enter vim, Pyright will try to detect Python and start, after you runPoetvActivate, Pyright doesn’t change anything. Maybe you can run:CocRestartafter:PoetvActivate, (I don’t try this works or not).python-versionis created and used by pyenv, you shouldn’t create it if you use poetry to manage your venvs. coc-pyright will try to runpoetry env list --full-pathif there is apoetry.lockfound.What’s
poetry env list --full-pathoutput in your project?pyrightconfig.jsonshould be in valid json format, This is the minimum content.I do think poetry creates virtualenvs actually, I wouldn’t think some other tool creates it.
$ vim:!which python:PoetvActivate:!which python