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
commit70456c227aad105addc573586672dd909f50c659 (patch)
tree9a1b784b90f3acd731694395347ab9b01c3a9a71 /modules/prog-python.el
parentb7c6b2c59a2ad74e8e886471ea57b2e87f812d4a (diff)
downloaddotemacs-70456c227aad105addc573586672dd909f50c659.tar.gz
dotemacs-70456c227aad105addc573586672dd909f50c659.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 a26b9760..5720e25e 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 ()