3

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

.gitlint.yaml我的 git repo 的根目录中有一个文件,其中包含,除其他外,

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 是由我以外的某个用户运行的。

4

2 回答 2

4

我看到test/unittest/test_gitlint.py

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

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

如果.gitlint.yaml自缓存写入后已更新,则应使输出缓存无效。
否则,您可以编辑配置以忽略错误类型,但在重新运行时它仍然存在。

于 2017-01-01T06:30:55.193 回答
1

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

然后,它根据pylint 搜索的方式选择了正确的 rcfile 。另外,我需要删除缓存目录:

rm -r ~/.git-lint/cache
于 2019-02-20T19:34:19.010 回答