1

我的 vim 配置存储在 subversion 中,位于https://stromberg.dnsalias.org/svn/vimrc/trunk

我经常在 linux 上使用它。它非常适合编辑 Python 代码;我使用 pyflakes、pydocstyle 和 pycodestyle。

我最近在做一个 Windows+Linux 项目,所以我也想在 Windows 10 上使用这个 vim 配置。它很好地完成了 pydocstyle 和 pycodestyle,但 pyflakes 出于某种原因被忽略了,即使我故意放入一些我知道 pyflakes 应该抱怨的东西——但正如我所提到的,pyflakes 只在 Windows 上失败,而不是在 Linux 上。我想在 Windows 上使用 pyflakes。

我已经盯着这个看了好几个小时了,但是当 pydocstyle 和 pycodestyle 很高兴时,我不明白为什么 pyflakes 会失败。

如果我运行:python3 -m pyflakes t.py ...在命令行中,一切似乎都运行良好,即使在 Windows 10 上也是如此。捕获到错误,退出代码为 1。

这是我的 t.py:

#!/usr/bin/env python3

"""Scrutinize how pyflakes is working."""


def main():
    """Scrutinize how pyflakes is working"""
    fred = 1
    print('hi')
    print(barney)


main()

export LC_CTYPE=en_US.UTF-8 在编辑 t.py 之前,我在 MSYS bash 中尝试过。pyflakes 的错误仍然被忽略。

我还尝试启用综合调试,其中:

let g:syntastic_debug_file = "~/syntastic.log"
let g:syntastic_debug = 3

...在我的 ~/_vimrc 中(名称在 Windows 上已更改)。

这会在 ~/syntastic.log 中产生以下内容:

syntastic: 15032.879527: g:syntastic_version = '3.9.0-20 (Vim 802, Windows, GUI)'
syntastic: 15032.884153: &shell = 'c:\windows\system32\cmd.exe', &shellcmdflag = '/c', &shellpipe = '>%s 2>&1', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '(', &autochdir = 0, &shellslash = 0, &shellxescape
 = '"&|<>()@^'
syntastic: 15032.889707: UpdateErrors (auto): default checkers
syntastic: 15032.893923: CacheErrors: default checkers
syntastic: 15032.898643: g:syntastic_aggregate_errors = 0
syntastic: 15032.901642: getcwd() = 'C:\Users\strom\src\orange-med\NKV-Gateway'
syntastic: 15032.905103: CacheErrors: Invoking checker: python/pyflakes
syntastic: 15032.910677: SyntasticMake: called with options: {'errorformat': '%E%f:%l: could not compile,%-Z%p^,%E%f:%l:%c: %m,%E%f:%l: %m,%-G%.%#', 'defaults': {'text': 'Syntax error'}, 'makeprg': 'pyflakes t.py', 'env': {}}
syntastic: 15035.560459: system: command run in 2.646106s
syntastic: 15035.563594: checker output: ['t.py:8:5 local variable ''fred'' is assigned to but never used', 't.py:10:11 undefined name ''barney''', '']
syntastic: 15035.566310: raw loclist: []
syntastic: 15035.569032: getLocList: checker python/pyflakes returned 1
syntastic: 15035.571879: python/pyflakes raw: []
syntastic: 15035.576068: quiet_messages filter: {}
syntastic: 15035.578621: getLocList: checker python/pyflakes run in 2.668662s
syntastic: 15035.581320: CacheErrors: Invoking checker: python/pycodestyle
syntastic: 15035.584226: SyntasticMake: called with options: {'subtype': 'Style', 'errorformat': '%f:%l:%c: %m', 'makeprg': 'pycodestyle t.py --max-line-len=131', 'env': {}}
syntastic: 15035.992649: system: command run in 0.404938s
syntastic: 15035.996063: checker output: ['']
syntastic: 15035.998649: raw loclist: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ''}]
syntastic: 15036.001299: getLocList: checker python/pycodestyle returned 0
syntastic: 15036.003611: python/pycodestyle raw: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'E', 'pattern': '', 'subtype': 'Style', 'text': ''}]
syntastic: 15036.006282: quiet_messages filter: {}
syntastic: 15036.008859: getLocList: checker python/pycodestyle run in 0.425115s
syntastic: 15036.011522: CacheErrors: Invoking checker: python/pydocstyle
syntastic: 15036.014535: SyntasticMake: called with options: {'subtype': 'Style', 'postprocess': ['compressWhitespace'], 'preprocess': 'killEmpty', 'errorformat': '%E%f:%l %.%#:,%+C        %m', 'makeprg': 'pydocstyle t.py --match=".*"', '
env': {}}
syntastic: 15036.945317: system: command run in 0.926581s
syntastic: 15036.948276: checker output: ['t.py:7 in public function `main`:', '        D400: First line should end with a period (not ''g'')', '']
syntastic: 15036.950823: preprocess: ['t.py:7 in public function `main`:', '        D400: First line should end with a period (not ''g'')']
syntastic: 15036.954283: raw loclist: [{'lnum': 7, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'E', 'pattern': '', 'text': '^@        D400: First line should end with a period (not ''g'')'}]
syntastic: 15036.957134: postprocess: [{'lnum': 7, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'E', 'pattern': '', 'subtype': 'Style', 'text': 'D400: First line should end with a period (not ''g'')'}]     
syntastic: 15036.959597: getLocList: checker python/pydocstyle returned 1
syntastic: 15036.961966: python/pydocstyle raw: [{'lnum': 7, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'E', 'pattern': '', 'subtype': 'Style', 'text': 'D400: First line should end with a period (not ''g'
')'}]
syntastic: 15036.965127: quiet_messages filter: {}
syntastic: 15036.967540: getLocList: checker python/pydocstyle run in 0.953626s
syntastic: 15036.971975: aggregated: {'_sorted': 0, '_name': 'pydocstyle (python)', '_owner': 1, '_columns': 1, '_rawLoclist': [{'lnum': 7, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'E', 'pattern': '', '
subtype': 'Style', 'text': 'D400: First line should end with a period (not ''g'')'}]}

...但即使这样似乎也不能告诉我出了什么问题。

这就是在 Linux 上我可能会转向 strace 的地方。

顺便说一句,vimrc 位于https://stromberg.dnsalias.org/svn/vimrc/trunk/hierarchy/.vimrc,最相关的部分是:

let g:syntastic_python_checkers = ['pyflakes', 'pycodestyle', 'pydocstyle']
function Py2()
  let g:syntastic_python_python_exec = '/usr/bin/python'
endfunction
function Py3()
  let g:syntastic_python_python_exec = '/usr/bin/python3'
endfunction
call Py3()   " default to Python3

顺便说一句,我尝试在我的 ~/_vimrc 中将 /usr/bin/python3 更改为简单的 'python3',但它似乎没有帮助。

哦,还有 :SyntasticInfo 给出:

Syntastic version: 3.9.0-20 (Vim 802, Windows, GUI)
Info for filetype: python
Global mode: active
Filetype python is active
The current file will be checked automatically
syntastic: 7.613563: system: command run in 0.175868s
Available checkers: pep257 pep8 pycodestyle pydocstyle pyflakes python
Currently enabled checkers: pyflakes pycodestyle pydocstyle
syntastic: 7.621995: &shell = 'c:\windows\system32\cmd.exe', &shellcmdflag = '/c', &shellpipe = '>%s 2>&1', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '(', &autochdir = 0, &shellslash = 0, &shellxescape = '
"&|<>()@^'

各位有什么建议吗?

4

0 回答 0