Skip to content

Instantly share code, notes, and snippets.

@FMCorz
Last active September 8, 2021 09:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save FMCorz/a12d26b6b11671486ab7b7d8b6710171 to your computer and use it in GitHub Desktop.
Save FMCorz/a12d26b6b11671486ab7b7d8b6710171 to your computer and use it in GitHub Desktop.
Sublime Text, Django and Pylint

Pre-requisites

  • Install SublimeLinter
  • Install SublineLinter-pylint

Global pylint

Install pylint globally.

pip install pylint

Check that pylint is in your PATH.

echo $PATH
which pylint

You may need to extend your PATH to contain the .local/bin folder.

vi ~/.profile

# Set PATH so it includes user's private local bin if it exists.
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Virtualenv

In your project's virtualenv, install pylint-django.

pip install pylint-django

Sublime project

From the menu Project > Edit project, adapt the path to Python, and add the django plugin.

{
	"folders":
	[
		{
			"path": "..."
		}
	],
	"SublimeLinter":
	{
		"@python": "/path/to/virtualenv/bin/python",
		"linters": {
			"pylint": {
				"args": ["--load-plugins=pylint_django"]
			}
		}
	}
}

.pylintrc

Create a .pylintrc file at the root of your project for fine tuning.

See also

Pylint documentation

@Shelagh-Lewins
Copy link

Thanks! This is really helpful. However I found that Sublime Linter recommended this form:

"settings": {
	"SublimeLinter.linters.pylint.python": "~/folder/folder/venv36/bin/python3.6",
        "SublimeLinter.linters.pylint.args": [
            "--load-plugins=pylint_django"
        ]
    }

I'm using Sublime Text 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment