Last active
August 29, 2015 14:05
-
-
Save andreasjansson/1cb4be3ad7c5b6b02e0b to your computer and use it in GitHub Desktop.
pylint-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun pylint-ignore () | |
| (interactive) | |
| (save-excursion | |
| (let* ((err (fly-get-err-at-point)) | |
| (err-str (flymake-ler-text err)) | |
| (err-code (nth 0 (fly-parse-message err-str)))) | |
| (end-of-line) | |
| (insert (concat " # pylint: disable=" err-code))))) | |
| (defun fly-parse-message (str) | |
| (string-match "\\[\\([^],]+\\)\\(?:, [^]]+\\)\\] \\(.+\\)" str) | |
| (let ((code (match-string 1 str)) | |
| (message (match-string 2 str))) | |
| (list code message))) | |
| (defun fly-get-err-at-point () | |
| (let ((err nil) | |
| (line-no (line-number-at-pos))) | |
| (dolist (elem flymake-err-info) | |
| (if (eq (car elem) line-no) | |
| (setq err (car (second elem))))) | |
| err)) | |
| ; requires pylint==0.28 | |
| (when (load "flymake" t) | |
| (defun flymake-pylint-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 "pylint" (list "-i" "y" "-d" "C" "-d" "R" "-d" "I" "-r" "n" "-f" "parseable" local-file)) | |
| )) | |
| (add-to-list 'flymake-allowed-file-name-masks | |
| '("\\.py\\'" flymake-pylint-init))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment