branch: elpa/flymake-pyrefly commit 61ba9c719f2d5bbe1e06a68be4fc19ee8dbc0baa Merge: 28f0ad6fde a3886b0f33 Author: Boris Shminke <1696493+inpef...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Merge pull request #25 from inpefess/12-raise-custom-error Define custom error --- flymake-pyrefly.el | 6 ++++-- tests/test-flymake-pyrefly.el | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/flymake-pyrefly.el b/flymake-pyrefly.el index 01982baedd..d77781504a 100644 --- a/flymake-pyrefly.el +++ b/flymake-pyrefly.el @@ -5,7 +5,7 @@ ;; Author: Boris Shminke <bo...@shminke.com> ;; Maintainer: Boris Shminke <bo...@shminke.com> ;; Created: 29 Jun 2025 -;; Version: 0.1.3 +;; Version: 0.1.4 ;; Keywords: tools, languages ;; URL: https://github.com/inpefess/flymake-pyrefly ;; Package-Requires: ((emacs "26.1")) @@ -39,12 +39,14 @@ (require 'cl-lib) (defvar-local pyrefly--flymake-proc nil) +(define-error 'no-pyrefly-error "Cannot find pyrefly") + (defun pyrefly-flymake-backend (report-fn &rest _args) "Report pyrefly diagnostic with REPORT-FN." ;; Not having pyrefly installed is a serious problem which should cause ;; the backend to disable itself, so an error is signaled. (unless (executable-find "pyrefly") - (error "Cannot find pyrefly")) + (signal 'no-pyrefly-error nil)) ;; If a live process launched in an earlier check was found, that ;; process is killed. When that process's sentinel eventually runs, diff --git a/tests/test-flymake-pyrefly.el b/tests/test-flymake-pyrefly.el index 170ddd70b0..9d7b487a7f 100644 --- a/tests/test-flymake-pyrefly.el +++ b/tests/test-flymake-pyrefly.el @@ -24,7 +24,8 @@ (ert-deftest flymake-pyrefly-test-no-pyrefly () "Test error message when Pyrefly is not found." (find-file "tests/example.py") - (should-error (pyrefly-flymake-backend 'identity))) + (should-error (pyrefly-flymake-backend 'identity) + :type 'no-pyrefly-error)) (ert-deftest flymake-pyrefly-test-normal-use-case () "Test a normal Pyrefly use-case." (defun mock-report-fn (args)