从pipenv中的vim ALE运行Pylint和MyPy时出现错误导入.--:!pylint%works--:!myp



我有一个项目目录

project
- code
- code.py
- tests
- test_code.py

过去,virtualenv一直在努力。我现在正在尝试pipenv。我的.virc 中有这个

"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捕获的错误。

我被难住了。有什么想法吗?

如果项目使用pipenv,请尝试使用let g:ale_python_auto_pipenv = 1。如果这对您不起作用,您可以使用:help ale-python-options中的各种选项设置工具的路径。

ALE:中有一个设置

let g:ale_python_pylint_change_directory=0
let g:ale_python_flake8_change_directory=0

如果不设置此项,ALE将在linting之前下降到项目子目录中。

相关内容

最新更新