这两天用着 Google 的 pytype
看了看,好像还没有 flycheck 的 checker,于是就自己写了个还不够完美的。用是能用了,只是少了点东西 (两行) 很不开心。
我写的是这样的:
(flycheck-def-args-var flycheck-python-pytype-args python-pytype)
(flycheck-define-checker python-pytype
"Pytype syntax checker.
See url `https://github.com/google/pytype`."
:command ("pytype"
(eval flycheck-python-pytype-args)
source-original)
:error-patterns
((warning line-start "File \"" (file-name) "\", line " line ", " (message (one-or-more (not (any "[")))) "[" (id (one-or-more not-newline)) "]"))
:modes python-mode
:predicate flycheck-buffer-saved-p
:next-checkers (python-flake8))
pytype 的输出是这样的:
λ≻ pytype temp.py
Computing dependencies
Analyzing 1 sources with 0 local dependencies
ninja: Entering directory `/Users/Nasy/temp/python/.pytype'
[1/1] check temp
FAILED: /Users/Nasy/temp/python/.pytype/pyi/temp.pyi
/Users/Nasy/.pyenv/versions/3.7.4/bin/python3.7 -m pytype.single --imports_info /Users/Nasy/temp/python/.pytype/imports/temp.imports --module-name temp -V 3.7 -o /Users/Nasy/temp/python/.pytype/pyi/temp.pyi --analyze-annotated --nofail --quick /Users/Nasy/temp/python/temp.py
File "/Users/Nasy/temp/python/temp.py", line 46, in unannotated: Missing parameter 'iterable' in call to function str.join [missing-parameter]
Expected: (self, iterable)
Actually passed: (self)
File "/Users/Nasy/temp/python/temp.py", line 50, in unannotated2: Function str.join expects 2 arg(s), got 3 [wrong-arg-count]
Expected: (self, iterable)
Actually passed: (self, iterable, _)
For more details, see https://google.github.io/pytype/errors.html.
ninja: build stopped: subcommand failed.
很显然,错误的信息应该在
File "/xxx/", line xx, message [id]
Expected:
Actually
这三行,我现在能匹配 第一行的那些了 但是该怎么一次性匹配这三行 message 呢?
顺便(这东西比 mypy 好用呢!)