Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore by directory using Pylint

Tags:

python

pylint

The following is from the Pylint documentation:

--ignore=<file>     Add <file or directory> to the black list. It should be a      base name, not a path. You may set this option multiple      times. [current: %default] 

Yet, I'm not having luck getting the directory part work.

I have directory called migrations, which has django-south migration files. As I enter --ignore=migrations, it still keeps giving me the errors/warnings in files inside the migrations directory.

Could it be that --ignore is not working for directories?

If I could even use a regular expression to match the ignored files, it would work, since django-south files are all named 0001_something, 0002_something...


Since I could not get the ignore by directory to work, I have resorted to simply putting # pylint: disable-msg-cat=WCREFI on top of each migration file, which ignores all Pylint errors, warnings, and information.

like image 316
Ciantic Avatar asked Mar 23 '10 21:03

Ciantic


People also ask

How do I ignore a folder in Pylint?

You can not give a path, but only the "basename" of the directory. E.g., use --ignore=lib instead of --ignore-=appengine-toolkit/gaetk/lib . The problem is you will ignore all directories named lib .

How do you ignore specific Pylint errors?

This may be done by adding # pylint: disable=some-message,another-one at the desired block level or at the end of the desired line of code.

How do I skip a file in Pylint?

The solution was to include --disable=file-ignored in the Pylint command options. It took way too long to figure this out; there shouldn't be a file-ignored error when you explicitly ignore a file. More ideally, put it in a pylintrc config file, not in a command option.


1 Answers

Adding the following to my .pylintrc files works with Pylint 0.25:

[MASTER] ignore=migrations 

My problems are with PyDev which (it seems) is not respecting my settings. This is due, I think, to the fact that it's running Pylint per-file, which I think bypasses 'ignore' checks - whether for modules/directories or files. The calls to Pylint from PyDev look like:

/path/to/site-packages/pylint/lint.py --include-ids=y /path/to/project/migrations/0018_migration.py 
like image 161
marqueed Avatar answered Sep 17 '22 19:09

marqueed