FMCorz
4/20/2017 - 4:30 AM

Sublime Text, Django and Pylint

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