git-lint pylint not running pylintrc file

1.8k views Asked by At

I am using git-lint for my Python project.

I have a .gitlint.yaml file in the root of my git repo, which contains, among other things,

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."

I have even created a ~/.config/pylintrc file, which contains, among other things,

indent-string=\t

But when i run git lint, no warnings are disabled, especially not the line 41, col 0: Warning: [mixed-indentation]: Found indentation with tabs instead of spaces warning.

I have concluded (and verified) that the ~/.config/pylintrc file isn't being processed at all.

Why is pylint ignoring all configuration options? What troubleshooting steps can I take? My best guess is that pylint, when executed by git lint, is run by some user other than me.

2

There are 2 answers

3
VonC On BEST ANSWER

I see in test/unittest/test_gitlint.py:

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

So your configuration should be in the right place.
But check if you don't have a cache issue (/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.

0
Anurag Nilesh On

I ran into the same issue. My workaround was to remove the rcfile argument line in the .gitlint.yaml file.

Then, it picked up the right rcfile based on how pylint searches for it. Also, I needed to delete the cache directory with:

rm -r ~/.git-lint/cache