我有一个项目目录
project
- code
- code.py
- tests
- test_code.py
过去使用virtualenv可以解决问题。我现在正在尝试pipenv。我的.vimrc中有这个
"python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
activate_this = os.path.join(project_base_dir, 'Scripts/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
这似乎可行。我使用:!python
获得了虚拟环境Python。我可以运行:!pylint
和:!mypy
,但它们都未安装在全局Python中。
:!pylint tests\
没有显示导入错误,但是ALE显示导入错误。 mypy也发生了类似的事情(并且更糟)。 Mypy不仅报告错误的导入错误(仅在通过ALE运行时),而且还会错过通过:!mypy tests\
捕获的错误。
我很困惑。有什么想法吗?
答案 0 :(得分:2)
如果您将let g:ale_python_auto_pipenv = 1
用于项目,请尝试使用pipenv
。如果这不适合您,则可以使用:help ale-python-options
中的各种选项来设置工具的路径。
答案 1 :(得分:-1)
ALE中有一个设置:
let g:ale_python_pylint_change_directory=0
let g:ale_python_flake8_change_directory=0
如果不设置此选项,ALE将在掉毛之前进入项目子目录。