简体   繁体   English

在 github 中用作预提交挂钩时,Pylint 不起作用

[英]Pylint not working when used as pre-commit hook in github

I am trying to use the following pre-commit hook to check my code quality.我正在尝试使用以下预提交挂钩来检查我的代码质量。 https://github.com/sebdah/git-pylint-commit-hook https://github.com/sebdah/git-pylint-commit-hook

I followed the instruction and installed it but it's displaying me a 0 score for all file.我按照说明安装了它,但它显示所有文件的分数为 0。 ex.前任。

Running pylint on make_postreq.py (file 5/15).. 0/10.00  FAILED ************* Module make_postreq

Whereas if I run pylint from the console, I get a decent score.而如果我从控制台运行pylint ,我会得到不错的分数。

Global evaluation
Your code has been rated at 8.75/10 (previous run: 8.75/10, +0.00)

I feel it might be a configuration issue, but can't seem to make it work.我觉得这可能是一个配置问题,但似乎无法使其工作。 Or is there some other way we can check our Python code quality before committing in GitHub?或者有没有其他方法可以在提交到 GitHub 之前检查我们的 Python 代码质量?

This issue may be caused by setting the files-output parameter in your pylintrc to yes .此问题可能是由于将 pylintrc 中的files-output参数设置为yes I just ran into this where I transferred a configuration file over.我刚刚遇到了这个,我在那里传输了一个配置文件。 The result processing in git-pylint-commit-hook requires that pylint print the final status to stdout, which is suppressed with files-output . git-pylint-commit-hook的结果处理要求pylint将最终状态打印到 stdout,这被files-output抑制。

Try to尝试

  1. set 'reports=yes' in [REPORTS] section在 [REPORTS] 部分设置 'reports=yes'
  2. don't disable 'RP0004'不要禁用“RP0004”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM