Pylint with Django

Viewed 1488

I have the following directory structure in a Django project:

.
├── config
├── element
├── home
├── static
├── templates
├── tree
└── user

I'm searching for the easiest command to run pylint on all directories that are python modules.

This would be all except 'static' and 'templates'.

I tested for example:

pylint --load-plugins=pylint_django --ignore=static/,templates/ */

But the ignore switch isn't working.

The following would work of course:

pylint --load-plugins=pylint_django config element home tree user

But I want it as dynamic as possible. When i add a new django app i could forget to update the pylint statement.


Edit: When i create the following .pylintrc,

[MASTER]
ignore=templates,static
load-plugins=pylint_django

and run pylint --rcfile=.pylintrc */

it gives this result:

************* Module static/__init__.py
static/__init__.py:1:0: F0001: No module named static/__init__.py (fatal)
************* Module templates/__init__.py
templates/__init__.py:1:0: F0001: No module named templates/__init__.py (fatal)

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Second edit: This behavior seems to come with the 'pylint_django' plugin. I opened an issue therefore.

1 Answers

You can specify --ignore multiple times:

pylint --ignore=static --ignore=templates */

Or you can make a .pylintrc file, that contains this:

[MASTER]
ignore=static,templates
Related