question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reportMissingModuleSource using poetv + pyenv + poetry + mypy

See original GitHub issue

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

image

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

image

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Liljacommented, Mar 2, 2021

@yaegassy Boom! There it is.

We use the umbrella directory as an “umbrella”-directory for all of our projects at my work. So it has a .git folder.

Perhaps Coc detects that it’s the workspace folder while it’s incorrect.

I added your snippet into my vimrc and voila!

image

For future readers, make sure to set b:coc_root_patterns!

1reaction
yaegassycommented, Mar 2, 2021

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.

" ...snip
  au FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json']
" ...snip

As a side note, by default, the directory where .git is located may be detected as the project root.

“coc.preferences.rootPatterns” settings, which default to [“.git”, “.hg”, “.projections.json”].

Read more comments on GitHub >

github_iconTop Results From Across the Web

mypy - Alex Mitelman
Intro The goal of this tutorial is to describe Python development ecosystem. It can be helpful for someone coming to Python from another...
Read more >
Managing Version, Virtual Environments and Dependencies ...
This article has covered the main points you need to know to use the pyenv + poetry combination for managing Python project independent ......
Read more >
pyenv: poetry itself, running on older python version, what to do?
The decision is to use Pyenv to install Poetry. If the older python version should be deleted: Uninstall Poetry. Delete old Python version....
Read more >
A modern set-up for Python package development
Dependency Management (and much more) with Poetry; Quality Assurance: black, mypy, pylint, pre-commit, pytest, coverage.py; CI/CD with Github ...
Read more >
Set up tests, linters and type checking in Python projects in 2020
poetry run mypy . A command to rule them all. We have added a lot of tools and checks in our project. And...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found