python.el: Adjustments to Flymake backend
* lisp/progmodes/python (python-flymake-command): Advertise possiblity to use pylint. (python-flymake-command-output-pattern): Make compatible with recent versions of pyflakes. (Bug#53913)
This commit is contained in:
parent
ec347aec0f
commit
275cef9e06
2 changed files with 43 additions and 5 deletions
|
@ -5648,9 +5648,13 @@ returned as is."
|
|||
This is a non empty list of strings, the checker tool possibly followed by
|
||||
required arguments. Once launched it will receive the Python source to be
|
||||
checked as its standard input.
|
||||
To use `flake8' you would set this to (\"flake8\" \"-\")."
|
||||
To use `flake8' you would set this to (\"flake8\" \"-\").
|
||||
To use `pylint' you would set this to (\"pylint\" \"--from-stdin\" \"stdin\")."
|
||||
:version "26.1"
|
||||
:type '(repeat string))
|
||||
:type '(choice (const :tag "Pyflakes" ("pyflakes"))
|
||||
(const :tag "Flake8" ("flake8" "-"))
|
||||
(const :tag "Pylint" ("pylint" "--from-stdin" "stdin"))
|
||||
(repeat :tag "Custom command" string)))
|
||||
|
||||
;; The default regexp accommodates for older pyflakes, which did not
|
||||
;; report the column number, and at the same time it's compatible with
|
||||
|
@ -5658,7 +5662,7 @@ To use `flake8' you would set this to (\"flake8\" \"-\")."
|
|||
;; TYPE
|
||||
(defcustom python-flymake-command-output-pattern
|
||||
(list
|
||||
"^\\(?:<?stdin>?\\):\\(?1:[0-9]+\\):\\(?:\\(?2:[0-9]+\\):\\)? \\(?3:.*\\)$"
|
||||
"^\\(?:<?stdin>?\\):\\(?1:[0-9]+\\):\\(?:\\(?2:[0-9]+\\):?\\)? \\(?3:.*\\)$"
|
||||
1 2 nil 3)
|
||||
"Specify how to parse the output of `python-flymake-command'.
|
||||
The value has the form (REGEXP LINE COLUMN TYPE MESSAGE): if
|
||||
|
@ -5670,7 +5674,6 @@ MESSAGE'th gives the message text itself.
|
|||
If COLUMN or TYPE are nil or that index didn't match, that
|
||||
information is not present on the matched line and a default will
|
||||
be used."
|
||||
:version "26.1"
|
||||
:type '(list regexp
|
||||
(integer :tag "Line's index")
|
||||
(choice
|
||||
|
@ -5679,7 +5682,8 @@ be used."
|
|||
(choice
|
||||
(const :tag "No type" nil)
|
||||
(integer :tag "Type's index"))
|
||||
(integer :tag "Message's index")))
|
||||
(integer :tag "Message's index"))
|
||||
:version "29.1")
|
||||
|
||||
(defcustom python-flymake-msg-alist
|
||||
'(("\\(^redefinition\\|.*unused.*\\|used$\\)" . :warning))
|
||||
|
|
|
@ -6300,6 +6300,40 @@ buffer with overlapping strings."
|
|||
a = 1
|
||||
")))
|
||||
|
||||
|
||||
;;; Flymake
|
||||
|
||||
(ert-deftest python-tests--flymake-command-output-pattern ()
|
||||
(pcase-let ((`(,patt ,line ,col ,type ,msg)
|
||||
python-flymake-command-output-pattern))
|
||||
;; Pyflakes output as of version 2.4.0
|
||||
(let ((output "<stdin>:12:34 'a.b.c as d' imported but unused"))
|
||||
(string-match patt output)
|
||||
(should (equal (match-string line output) "12"))
|
||||
(when col (should (equal (match-string col output) "34")))
|
||||
(should (equal (match-string msg output)
|
||||
"'a.b.c as d' imported but unused")))
|
||||
;; Flake8 output as of version 4.0.1
|
||||
(let ((output "stdin:12:34: F401 'a.b.c as d' imported but unused"))
|
||||
(string-match patt output)
|
||||
(should (equal (match-string line output) "12"))
|
||||
(when col (should (equal (match-string col output) "34")))
|
||||
(when type (should (equal (match-string type output) "F401")))
|
||||
(should (equal (match-string msg output)
|
||||
(if type
|
||||
"'a.b.c as d' imported but unused"
|
||||
"F401 'a.b.c as d' imported but unused"))))
|
||||
;; Pylint output as of version 2.14.5
|
||||
(let ((output "stdin:12:34: W0611: Unused import a.b.c (unused-import)"))
|
||||
(string-match patt output)
|
||||
(should (equal (match-string line output) "12"))
|
||||
(when col (should (equal (match-string col output) "34")))
|
||||
(when type (should (equal (match-string type output) "W0611")))
|
||||
(should (equal (match-string msg output)
|
||||
(if type
|
||||
"Unused import a.b.c (unused-import)"
|
||||
"W0611: Unused import a.b.c (unused-import)"))))))
|
||||
|
||||
(provide 'python-tests)
|
||||
|
||||
;;; python-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue