aboutsummaryrefslogtreecommitdiff
path: root/modules/prog-python.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-12 11:40:39 -0500
committerCraig Jennings <c@cjennings.net>2026-05-12 11:40:39 -0500
commit49ab1b693f90ebef6c94bf47c6d9be66f5105c5f (patch)
tree265380e6eff9c308f3cc06ee24b28866c2260418 /modules/prog-python.el
parentf9720c657217ea421d91caf326e756aabe2aad44 (diff)
downloaddotemacs-49ab1b693f90ebef6c94bf47c6d9be66f5105c5f.tar.gz
dotemacs-49ab1b693f90ebef6c94bf47c6d9be66f5105c5f.zip
refactor(prog-python): extract the mypy and pdb command builders
I pulled the command-string construction out of `cj/python-mypy` and `cj/python-debug` into `cj/--python-mypy-command` and `cj/--python-debug-command`. The wrappers stay thin — resolve the target, hand off to `compile` or `pdb`. With the command shape in a pure helper I can unit-test it directly instead of stubbing `compile` and `pdb`.
Diffstat (limited to 'modules/prog-python.el')
-rw-r--r--modules/prog-python.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/prog-python.el b/modules/prog-python.el
index a26b9760c..5720e25e3 100644
--- a/modules/prog-python.el
+++ b/modules/prog-python.el
@@ -57,19 +57,26 @@ Install with: pip install mypy")
(executable-find pyright-path))
(lsp-deferred)))
+(defun cj/--python-mypy-command (target)
+ "Return the shell command that runs mypy against TARGET."
+ (format "%s %s" mypy-path (shell-quote-argument target)))
+
+(defun cj/--python-debug-command (file)
+ "Return the shell command that runs pdb against FILE."
+ (format "python3 -m pdb %s" (shell-quote-argument file)))
+
(defun cj/python-mypy ()
"Run mypy static type checker on the current Python file or directory."
(interactive)
(if (executable-find mypy-path)
- (let ((target (or (buffer-file-name) default-directory)))
- (compile (format "%s %s" mypy-path (shell-quote-argument target))))
+ (compile (cj/--python-mypy-command (or (buffer-file-name) default-directory)))
(message "mypy not found. Install with: pip install mypy")))
(defun cj/python-debug ()
"Start Python debugger (pdb) on the current file."
(interactive)
(if buffer-file-name
- (pdb (format "python3 -m pdb %s" (shell-quote-argument buffer-file-name)))
+ (pdb (cj/--python-debug-command buffer-file-name))
(message "No file associated with this buffer")))
(defun cj/python-mode-keybindings ()