Search code examples
pythonemacspylintpep8pyflakes

How can I use Emacs Flymake mode for python with pyflakes and pylint checking code?


For checking code in python mode I use flymake with pyflakes

Also I want check code style (pep8) with pylint (description on the same page with pyflakes)

This solutions work. But I can't configure flymake for work with pyflakes and pylint together. How can I do it?


Solution

  • Well, flymake is just looking for a executable command thats output lines in a predefined format. You can make a shell script for example that will call successively all the checkers you want...

    You must also make sure that your script ends by returning errorlevel 0. So this is an example:

    This is what I've done in a "pycheckers" script:

    #!/bin/bash
    
    epylint "$1" 2>/dev/null
    pyflakes "$1"
    pep8 --ignore=E221,E701,E202 --repeat "$1"
    true
    

    For the emacs lisp part:

    (when (load "flymake" t)
      (defun flymake-pyflakes-init ()
        (let* ((temp-file (flymake-init-create-temp-buffer-copy
                           'flymake-create-temp-inplace))
               (local-file (file-relative-name
                            temp-file
                            (file-name-directory buffer-file-name))))
          (list "pycheckers"  (list local-file))))
      (add-to-list 'flymake-allowed-file-name-masks
                   '("\\.py\\'" flymake-pyflakes-init)))