branch: elpa/flymake-pyrefly commit 2059935c0d9183486e2a068eb85ced81a9360d15 Merge: 4e8430b6c0 32e82974b1 Author: Boris Shminke <1696493+inpef...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Merge pull request #16 from inpefess/8-pass-column-numbers-to-flymake Pass column to Pyrefly --- flymake-pyrefly.el | 17 +++++++++-------- tests/test-flymake-pyrefly.el | 13 ++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flymake-pyrefly.el b/flymake-pyrefly.el index 0eacba7e53..2d5b0d4646 100644 --- a/flymake-pyrefly.el +++ b/flymake-pyrefly.el @@ -43,7 +43,7 @@ ;; Save the current buffer, the narrowing restriction, remove any ;; narrowing restriction. ;; - (let ((source (current-buffer))) + (let ((source (current-buffer)) (source-file-name buffer-file-name)) (save-restriction (widen) ;; Reset the `pyrefly--flymake-proc' process to a new process @@ -59,7 +59,7 @@ :command (append '("pyrefly" "check" "--output-format" "min-text" "--no-summary") - (list buffer-file-name)) + (list source-file-name)) :sentinel (lambda (proc _event) ;; Check that the process has indeed exited, as it might @@ -80,17 +80,18 @@ ;; (cl-loop while (search-forward-regexp - "^\\([A-Z]+\\) .+\.py:\\([0-9]+\\):[0-9]+\-[0-9]+: \\(.*\\)$" + "^\\([A-Z]+\\) .+\.py:\\([0-9]+\\):\\([0-9]+\\)\-\\([0-9]+\\): \\(.*\\)$" nil t) - for msg = (match-string 3) - for (beg . end) = (flymake-diag-region - source - (string-to-number (match-string 2))) + for msg = (match-string 5) + for beg = (cons (string-to-number (match-string 2)) + (string-to-number (match-string 3))) + for end = (cons (string-to-number (match-string 2)) + (string-to-number (match-string 4))) for type = (if (equal "ERROR" (match-string 1)) :error :warning) when (and beg end) - collect (flymake-make-diagnostic source + collect (flymake-make-diagnostic source-file-name beg end type diff --git a/tests/test-flymake-pyrefly.el b/tests/test-flymake-pyrefly.el index f518925370..27bd37d51b 100644 --- a/tests/test-flymake-pyrefly.el +++ b/tests/test-flymake-pyrefly.el @@ -25,16 +25,15 @@ (should-error (flymake-pyrefly 'identity))) (ert-deftest flymake-pyrefly-test-normal-use-case () "Test a normal Pyrefly use-case." - (let ((saved-args nil) - (mock-report-fn (lambda (args) (setq saved-args args)))) + (defun mock-report-fn (args) + (setq saved-args args)) (find-file "example.py") - (flymake-pyrefly mock-report-fn) - (flymake-pyrefly mock-report-fn) + (setq saved-args nil) + (flymake-pyrefly 'mock-report-fn) + (flymake-pyrefly 'mock-report-fn) (sleep-for 1) (should - (equal - (aref (car saved-args) 5) - "`Literal[0]` is not assignable to variable `x` with type `str` [bad-assignment]")))) + (equal (aref (car saved-args) 2) (cons 2 5)))) (ert-deftest flymake-pyrefly-test-setup () (pyrefly-setup-flymake-backend) (should (member 'flymake-pyrefly flymake-diagnostic-functions)))