소스 검색

Fix and enable python-black flycheck checker

master
10sr 5 년 전
부모
커밋
34946093c8
로그인 계정: 10sr GPG 키 ID: 7BEC428194130EB2
1개의 변경된 파일28개의 추가작업 그리고 4개의 파일을 삭제
  1. +28
    -4
      emacs.el

+ 28
- 4
emacs.el 파일 보기

@@ -2030,12 +2030,25 @@ initializing."

(require 'flycheck)

'(flycheck-define-checker python-black
(flycheck-define-checker python-black
"A Python style checker."
:command ("python3"
"-m" "black"
(config-file "--config" flycheck-black)
"--check" source)
:error-parser my-flycheck-parse-any-error
:enabled (lambda ()
(or (not (flycheck-python-needs-module-p 'python-black))
(flycheck-python-find-module 'python-black "black")))
:verify (lambda (_) (flycheck-python-verify-module 'python-black "black"))
:modes python-mode)

'(flycheck-define-checker python-black-diff
"A Python style checker."
:command ("python3"
"-m" "black"
(config-file "--config" flycheck-black)
"--check" source)
"--diff" source)
:error-parser my-flycheck-parse-unified-diff
:enabled (lambda ()
(or (not (flycheck-python-needs-module-p 'python-black))
@@ -2050,8 +2063,19 @@ initializing."
'python-black)

(defun my-flycheck-parse-any-error (output checker buffer)
"Flycheck parser to check if OUTPUT is not empty."
())
"Flycheck parser to check if reformat is required."
(with-temp-buffer
(insert output)
(goto-char (point-min))
(when (re-search-forward "^would reformat .*$" nil t)
(list (flycheck-error-new-at
(point-min)
nil
'error
;;(format "Black: %s" (match-string 0))
"Black: would reformat buffer"
:buffer buffer
:checker checker)))))

(defun my-flycheck-parse-unified-diff (output checker buffer)
"Flycheck parser to parse diff output."


불러오는 중...
취소
저장