3

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.

mareoraft
  • 3,474
  • 4
  • 26
  • 62

2 Answers2

4

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You're right, there was a cache issue. And I guess there's no solution for that issue either. Also, I've confirmed that the `{DEFAULT_CONFIGS}/.pylintrc` path wasn't working either. When I replace it with an absolute path, it works. Do you know where I can set the `DEFAULT_CONFIGS` variable? – mareoraft Jan 01 '17 at 22:09
  • @mareoraft not sure: I see it defined here: https://github.com/sk-/git-lint/blob/34d738e0a2a12828b28cd0556d1a20447357c0fa/gitlint/linters.py#L137-L139. And I can see for v0.0.5 (https://github.com/sk-/git-lint/blob/34d738e0a2a12828b28cd0556d1a20447357c0fa/README.rst#v005-2014-05-09) that "variables `%(REPO_HOME)` and `%(DEFAULT_CONFIGS)` can be specified in configuration" – VonC Jan 01 '17 at 22:41
  • 3
    They fail to explain where and how those variables should be specified. – mareoraft Jan 02 '17 at 04:22
1

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
double-beep
  • 5,031
  • 17
  • 33
  • 41