Editor and IDE integration

To use Pylint with:

Pylint is integrated in:

Using Pylint thru flymake in Emacs

To enable flymake for Python, insert the following into your .emacs:

;; Configure flymake for Python
(when (load "flymake" t)
  (defun flymake-pylint-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
           (local-file (file-relative-name
                        (file-name-directory buffer-file-name))))
      (list "epylint" (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.py\\'" flymake-pylint-init)))

;; Set as a minor mode for Python
(add-hook 'python-mode-hook '(lambda () (flymake-mode)))

Above stuff is in pylint/elisp/pylint-flymake.el, which should be automatically installed on Debian systems, in which cases you don’t have to put it in your .emacs file.

Other things you may find useful to set:

;; Configure to wait a bit longer after edits before starting
(setq-default flymake-no-changes-timeout '3)

;; Keymaps to navigate to the errors
(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-cn" 'flymake-goto-next-error)))
(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-cp" 'flymake-goto-prev-error)))

Finally, by default flymake only displays the extra information about the error when you hover the mouse over the highlighted line. The following will use the minibuffer to display messages when you the cursor is on the line.

;; To avoid having to mouse hover for the error message, these functions make flymake error messages
;; appear in the minibuffer
(defun show-fly-err-at-point ()
  "If the cursor is sitting on a flymake error, display the message in the minibuffer"
  (require 'cl)
  (let ((line-no (line-number-at-pos)))
    (dolist (elem flymake-err-info)
      (if (eq (car elem) line-no)
      (let ((err (car (second elem))))
        (message "%s" (flymake-ler-text err)))))))

(add-hook 'post-command-hook 'show-fly-err-at-point)

Alternative, if you only wish to pollute the minibuffer after an explicit flymake-goto-* then use the following instead of a post-command-hook

(defadvice flymake-goto-next-error (after display-message activate compile)
  "Display the error in the mini-buffer rather than having to mouse over it"

(defadvice flymake-goto-prev-error (after display-message activate compile)
  "Display the error in the mini-buffer rather than having to mouse over it"

Setup the MS Visual Studio .NET 2003 editor to call Pylint


The output of Pylint is then shown in the “Output” pane of the editor.

Integrate Pylint with TextMate

Install Pylint in the usual way:

pip install pylint

Install the Python bundle for TextMate:

  1. select TextMate > Preferences
  2. select the Bundles tab
  3. find and tick the Python bundle in the list

You should now see it in Bundles > Python.

In Preferences, select the Variables tab. If a TM_PYCHECKER variable is not already listed, add it, with the value pylint.

The default keyboard shortcut to run the syntax checker is Control-Shift-V - open a .py file in Textmate, and try it.

You should see the output in a new window:

PyCheckMate 1.2 – Pylint 1.4.4

No config file found, using default configuration

Then all is well, and most likely Pylint will have expressed some opinions about your Python code (or will exit with 0 if your code already conforms to its expectations).

If you receive a message:

Please install PyChecker, PyFlakes, Pylint, PEP 8 or flake8 for more extensive code checking.

That means that Pylint wasn’t found, which is likely an issue with command paths - TextMate needs be looking for Pylint on the right paths.

Check where Pylint has been installed, using which:

$ which pylint

The output will tell you where Pylint can be found; in this case, in /usr/local/bin.

  1. select TextMate > Preferences
  2. select the Variables tab
  3. find and check that a PATH variable exists, and that it contains the appropriate path (if the path to Pylint were /usr/local/bin/pylint as above, then the variable would need to contain /usr/local/bin). An actual example in this case might be $PATH:/opt/local/bin:/usr/local/bin:/usr/texbin, which includes other paths.

... and try running Pylint again.

Table Of Contents

Previous topic

Extending Pylint

Next topic


This Page