git-lint pylint 不是 运行 pylintrc 文件

git-lint pylint not running pylintrc file

我正在为我的 Python 项目使用 git-lint

我的 git 存储库的根目录中有一个 .gitlint.yaml 文件,其中包含

pylint:
  extensions:
  - .py
  command: pylint
  arguments:
  - "--rcfile={DEFAULT_CONFIGS}/.pylintrc" # doesn't seem to work
  - "--disable=all" # doesn't work either
  - "--output-format=text"
  - "--msg-template='{{abspath}}:{{line}}:{{column}}: [{{category}}:{{symbol}}] {{obj}}: {{msg}}'"
  - "--reports=n"
  filter: "^{filename}:(?P<line>{lines}):((?P<column>\d+):)? \[(?P<severity>.+):(?P<message_id>\S+)\]\s+(: )?(?P<message>.+)$"
  installation: "Run pip install pylint."

我什至创建了一个 ~/.config/pylintrc 文件,其中包含

indent-string=\t

但是当我 运行 git lint 时,没有警告被禁用,尤其是 line 41, col 0: Warning: [mixed-indentation]: Found indentation with tabs instead of spaces 警告。

我得出结论(并验证)~/.config/pylintrc 文件根本没有被处理。

为什么 pylint 忽略所有配置选项?我可以采取哪些故障排除步骤?我最好的猜测是,当由 git lint 执行时,pylint 是由除我以外的其他用户 运行。

我在 test/unittest/test_gitlint.py 中看到:

self.root = '/home/user/repo'
git_config = os.path.join(self.root, '.gitlint.yaml')

所以你的配置应该在正确的地方。
但是请检查您是否没有缓存问题 (/home/user/.git-lint/cache), as mentioned in issue 34.

If .gitlint.yaml has been updated since the cache was written, the output cache should be invalidated.
Otherwise, you could edit the config to eg ignore an error type, but it'll still be present when rerunning.

我运行遇到了同样的问题。我的解决方法是删除 .gitlint.yaml 文件中的 rcfile 参数行。

然后,它根据how pylint searches for it选择了正确的rcfile。另外,我需要删除缓存目录:

rm -r ~/.git-lint/cache