问题描述
为了在 python 模式下检查代码,我使用 flymake 和 pyflakes
For checking code in python mode I use flymake with pyflakes
我还想用pylint检查代码样式(pep8)(与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)))
这篇关于如何使用带有 pyflakes 和 pylint 检查代码的 Python 的 Emacs Flymake 模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!