从pipenv中的vim ALE运行Pylint和MyPy的错误导入错误.-- :!pylint % 有效 -- :!mypy % 有效 [英] False import errors running Pylint and MyPy from vim ALE in pipenv. -- :!pylint % works -- :!mypy % works

查看:41
本文介绍了从pipenv中的vim ALE运行Pylint和MyPy的错误导入错误.-- :!pylint % 有效 -- :!mypy % 有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目目录

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

过去,virtualenv 已经奏效了.我现在正在尝试pipenv.我的 .vimrc 中有这个

Things have worked in the past with virtualenv. I am now trying pipenv. I have this in my .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 中.

That seems to work. I get my virtual environment Python with :!python. I can run :!pylint and :!mypy, neither of which are installed in my global Python.

:!pylint tests\ 没有显示导入错误,但 ALE 显示导入错误.类似的事情(甚至更糟)发生在 mypy 上.Mypy 不仅会报告错误的导入错误(仅当通过 ALE 运行时),还会错过通过 :!mypy tests\ 捕获的错误.

:!pylint tests\ shows no import errors, but ALE is showing import-error. A similar thing (and worse) happens with mypy. Mypy not only reports false import errors (only when run through ALE), but also misses errors that it catches through :!mypy tests\.

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

I'm stumped. Any ideas?

推荐答案

ALE 中有一个设置:

There is a setting in ALE:

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

如果您不设置此项,ALE 将在 linting 之前进入项目子目录.

If you do not set this, ALE will descend into project subdirectories before linting.

这篇关于从pipenv中的vim ALE运行Pylint和MyPy的错误导入错误.-- :!pylint % 有效 -- :!mypy % 有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆