python - 在 python 3.5 中预提交的 Pylint 设置
问题描述
我试图在我的项目中进行pylint
设置pre-commit
。
我来到了这个答案,他们告诉他们如何设置我的.pre-commit-config.yaml
.
当我去答案中提到的存储库时,他们写道
此镜像仓库已弃用,直接使用pylint。
所以我这样设置我的.pre-commit-config.yaml
文件
- repo: https://github.com/pycqa/pylint
rev: pylint-2.4.4
hooks:
- id: pylint
args:
- --limit=8
- --rcfile=$PROJECT_ROOT/.pylintrc
但是现在当我尝试做
$ pre-commit run
它给出了以下错误:
An unexpected error has occurred: CalledProcessError: command: ('/Users/userabc/.cache/pre-commit/repokxyo7uuq/py_env-default/bin/python', '/Users/userabc/.cache/pre-commit/repokxyo7uuq/py_env-default/bin/pip', 'install', '.')
return code: 1
expected return code: 0
stdout:
Processing /Users/userabc/.cache/pre-commit/repokxyo7uuq
stderr:
ERROR: Command errored out with exit status 1:
command: /Users/userabc/.cache/pre-commit/repokxyo7uuq/py_env-default/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/pip-req-build-5vjdd9f2/setup.py'"'"'; __file__='"'"'/private/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/pip-req-build-5vjdd9f2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/pip-req-build-5vjdd9f2/pip-egg-info
cwd: /private/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/pip-req-build-5vjdd9f2/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/pip-req-build-5vjdd9f2/setup.py", line 60, in <module>
long_description = stream.read()
File "/Users/userabc/.pyenv/versions/3.5.2/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4020: ordinal not in range(128)
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Check the log at /Users/userabc/.cache/pre-commit/pre-commit.log
我的项目和虚拟环境的 python 版本是3.5.2
.
这是pylint
或中的错误pre-commit
吗?还是我做错了什么?
解决方案
看起来您在设置了损坏/不正确的语言环境的环境中运行。
通过运行搜索您当前的语言环境设置env | grep -E '(LC|LANG)'
,也许python3 -m locale
如果配置正确,python 应该选择UTF-8
编码 - 通常你可以更正任何.bashrc
/ etc. 设置为无效的语言环境,或者你可以自己设置它
一个常见的值是:LANG=C.UTF-8
或LANG=en_US.UTF-8
编辑:我也在这里修复 pylint
推荐阅读
- angular - iframe (WooCommerce) 并在 Ionic 应用程序中使用 Facebook 登录
- mongodb - MongoDB mongod 未运行
- c# - 使用 Microsoft Graph 创建新日历
- c++ - C++ boost::asio::ip::tcp::acceptor 有时不接受连接器?
- c++ - 错误:无法解析对重载函数的引用;你的意思是叫它吗?
- magento - Stripe Payment - 卸载噩梦
- dart - Dart - 获取列表中的总金额
- javascript - 递归地从json中查找依赖项
- php - 数组项计数
- xml - 如何从 \Yii::$app->request 中检索 XML 数据?