fix(python): HTTP request from pip-requirements-mode
pip-requirements-mode fetches the pypi.org package list via HTTP request, which blocks. This can sometimes take unbearably long in cases where the user has a slow or no internet connection. This fix defers this behavior until the first time completion is invoked. Fix: #5998
This commit is contained in:
parent
f7e127af58
commit
04b76fd0ce
1 changed files with 18 additions and 0 deletions
|
@ -311,6 +311,24 @@
|
||||||
:after cython-mode)
|
:after cython-mode)
|
||||||
|
|
||||||
|
|
||||||
|
(use-package! pip-requirements
|
||||||
|
:defer t
|
||||||
|
:config
|
||||||
|
;; HACK `pip-requirements-mode' performs a sudden HTTP request to
|
||||||
|
;; https://pypi.org/simple, which causes unexpected hangs (see #5998). This
|
||||||
|
;; advice defers this behavior until the first time completion is invoked.
|
||||||
|
;; REVIEW More sensible behavior should be PRed upstream.
|
||||||
|
(defadvice! +python--init-completion-a (&rest args)
|
||||||
|
"Call `pip-requirements-fetch-packages' first time completion is invoked."
|
||||||
|
:before #'pip-requirements-complete-at-point
|
||||||
|
(unless pip-packages (pip-requirements-fetch-packages)))
|
||||||
|
(defadvice! +python--inhibit-pip-requirements-fetch-packages-a (fn &rest args)
|
||||||
|
"No-op `pip-requirements-fetch-packages', which can be expensive."
|
||||||
|
:around #'pip-requirements-mode
|
||||||
|
(letf ((#'pip-requirements-fetch-packages #'ignore))
|
||||||
|
(apply fn args))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; LSP
|
;;; LSP
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue