0

I have installed and configured and ran pylint like this:

pip install pylint==2.15.3
pylint --generate-rcfile > pylintrc
pylint ./*

However, it is complaining about several non-python files (pylintrc, pytest.ini, various markdown files, etc.)

An example of a few of those complaints:

************* Module README README.rst:1:6: E0001: Parsing failed: 'invalid syntax (, line 1)' (syntax-error) ************* Module pylintrc pylintrc:6:1: E0001: Parsing failed: 'cannot assign to operator (, line 6)' (syntax-error) ************* Module pytest pytest.ini:2:12: E0001: Parsing failed: 'invalid syntax (, line 2)' (syntax-error)

First, this is very surprising, I'd expect pylint to automatically only care about *.py files.

I've tried quite a bit of searching since this seems like it should be a very common problem, but no luck so far.

I've tried setting the [MAIN] ignore since that sounds promising, and looks like it works for others, but no luck. This is what I have for it:

[MAIN]
ignore=
      CVS,
      README.rst
      README.md
      *.rst,
      *.md,
      pylintrc,
      pytest,
      *.txt,
      *.toml

I tried without any wildcards since I read they aren't supported, but no improvement there.

I also tried configuring ignored-modules similarly to what I have for ignore, but no luck there.

I've also tried enumerating things on the command line via:

pylint --ignore=README.rst --ignore=*.md ./*

but no luck there either.

I did have some success finally with the ignore patterns when configured like below, but that can't possibly be the right way to do things?

ignore-patterns=(^\.#)|(.*\.md)|(.*\.rst)|(pytest\.ini)

Is there any way to configure pylint to only care about *.py files? Or if that isn't possible what is the right way to configure pylint to exclude and ignore files I don't want it to look at?

jcrv
  • 647
  • 7
  • 18
davidpricedev
  • 2,107
  • 2
  • 20
  • 34
  • 1
    Does this answer your question? [Run Pylint for all Python files in a directory and all subdirectories](https://stackoverflow.com/questions/36873096/run-pylint-for-all-python-files-in-a-directory-and-all-subdirectories) – SuperStormer Oct 08 '22 at 20:33
  • 1
    "I'd expect pylint to automatically only care about *.py files." - well, if you explicitly pass a README file to it, it assumes that you know what you're doing and scans it anyways. – SuperStormer Oct 08 '22 at 20:34
  • @SuperStormer, no it doesn't. I found that before posting here but there is nothing there that directly answers this question. There is nothing I see in that post that even mentions `./*` – davidpricedev Oct 08 '22 at 20:42
  • 1
    See https://stackoverflow.com/a/73227403/2519059 – Pierre.Sassoulas Oct 08 '22 at 20:56

1 Answers1

0

I found an answer. If I change the syntax of invoking pylint ever so subtly and run pylint ./project instead of pylint ./* it suddenly behaves as expected - ignoring non-python files.

davidpricedev
  • 2,107
  • 2
  • 20
  • 34