Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): add support for Python 3.12 and later #2055

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions elpy-rpc.el
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,21 @@ needed packages from `elpy-rpc--get-package-list'."
(t
(error "Invalid value for `elpy-rpc-virtualenv-path', please set it to a proper value using customize"))))

(defun elpy-rpc--get-pip-dependencies (python-version)
"Return a list of RPC dependencies, based on the current PYTHON-VERSION."
(let*
((basic-py-deps '("jedi" "flake8" "autopep8" "yapf"))
(common-py-deps (cons "black" basic-py-deps))
(modern-py-deps (cons "setuptools" common-py-deps)))

(cond ((version< python-version "3.6") basic-py-deps)
((version< python-version "3.12") common-py-deps)
(t modern-py-deps))))

(defun elpy-rpc--get-package-list ()
"Return the list of packages to be installed in the RPC virtualenv."
(let ((rpc-python-version (elpy-rpc--get-python-version)))
(if (version< rpc-python-version "3.6.0")
'("jedi" "flake8" "autopep8" "yapf")
'("jedi" "flake8" "autopep8" "yapf" "black"))))
(elpy-rpc--get-pip-dependencies rpc-python-version)))

(defun elpy-rpc--get-python-version ()
"Return the RPC python version."
Expand Down
7 changes: 7 additions & 0 deletions test/elpy-rpc--get-pip-dependencies-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;;; -*-coding: utf-8-*-

(ert-deftest elpy-rpc-get-pip-dependencies-should-return-packages-dependent-on-current-python-version ()
(elpy-testcase ()
(should (equal '("jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.5.0")))
(should (equal '("black" "jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.6.0")))
(should (equal '("setuptools" "black" "jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.12.0")))))
Loading