From f366c19f79bbadcf6e23cb77ec1997b88eb773f0 Mon Sep 17 00:00:00 2001 From: Evgenii Klimov Date: Wed, 28 Feb 2024 10:33:49 +0000 Subject: [PATCH 1/2] le-python.el (lispy--python-poetry-name): Don't fail outside of project File can be outside of project (so no root) or may not use poetry/pyproject.toml. --- le-python.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/le-python.el b/le-python.el index 57368da5..cc4e578c 100644 --- a/le-python.el +++ b/le-python.el @@ -298,8 +298,8 @@ it at one time." (defvar lispy--python-init-file nil) (defun lispy--python-poetry-name () - (let ((pyproject - (file-name-directory (locate-dominating-file (buffer-file-name) "pyproject.toml")))) + (when-let* ((root (locate-dominating-file (buffer-file-name) "pyproject.toml")) + (pyproject (file-name-directory root))) (and (file-exists-p pyproject) (not (equal python-shell-interpreter "python")) (with-current-buffer (find-file-noselect pyproject) From 67cba0e02a50cb5e0710927cef4ffc4891d51981 Mon Sep 17 00:00:00 2001 From: Evgenii Klimov Date: Fri, 1 Mar 2024 21:16:49 +0000 Subject: [PATCH 2/2] Don't break in buffer not visiting a file * le-python.el (lispy--python-poetry-name): Fix --- le-python.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/le-python.el b/le-python.el index cc4e578c..71b75710 100644 --- a/le-python.el +++ b/le-python.el @@ -298,7 +298,8 @@ it at one time." (defvar lispy--python-init-file nil) (defun lispy--python-poetry-name () - (when-let* ((root (locate-dominating-file (buffer-file-name) "pyproject.toml")) + (when-let* ((bfn (buffer-file-name)) + (root (locate-dominating-file bfn "pyproject.toml")) (pyproject (file-name-directory root))) (and (file-exists-p pyproject) (not (equal python-shell-interpreter "python"))