如何使用Emacs Flymake模式进行python与pyflakes和pylint检查代码? [英] How can I use Emacs Flymake mode for python with pyflakes and pylint checking code?

查看:249
本文介绍了如何使用Emacs Flymake模式进行python与pyflakes和pylint检查代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了检查python模式中的代码,我使用flymake与 pyflakes

For checking code in python mode I use flymake with pyflakes

此外,我还要检查代码样式(pep8)与pylint(与pyflakes在同一页面上的描述)

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

此解决方
但是我不能配置flymake来与pyflakes和pylint一起工作。
我该怎么做?

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

推荐答案

嗯,flymake只是寻找一个可执行命令,预定格式。您可以制作一个shell脚本,例如,将连续调用所有需要的检查程序...

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...

您还必须确保脚本以返回错误级别0结束。这是一个例子:

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

这是我在pycheckers脚本中所做的:

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

对于emacs lisp部分:

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)))

这篇关于如何使用Emacs Flymake模式进行python与pyflakes和pylint检查代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆