diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-05-22 07:31:18 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-05-22 07:31:18 +0100 |
commit | 908778078736bd36f7a60a2d576d415cb8e000fa (patch) | |
tree | c6a4796c48b608c14dc7e9674cdbd38f905e3c15 /dev-python/python-lsp-server | |
parent | 185fa19bbf68a4d4dca534d2b46729207a177f16 (diff) |
gentoo resync : 22.05.2021
Diffstat (limited to 'dev-python/python-lsp-server')
4 files changed, 327 insertions, 0 deletions
diff --git a/dev-python/python-lsp-server/Manifest b/dev-python/python-lsp-server/Manifest new file mode 100644 index 000000000000..a34917e7a7f3 --- /dev/null +++ b/dev-python/python-lsp-server/Manifest @@ -0,0 +1,4 @@ +AUX pyls-fix-test-with-pylint28.patch 9964 BLAKE2B 8f8f4a2a874f0f4a3b146463301b997b82a0b05d662451faf77994ede1057f7be71e2916d74944e0b30fb6d6c0d7b7a9bf5eb651085033b2279974d2005191a2 SHA512 248bfc639c6e534ddaa7775ec09e8c108e1ab8b071b99e2b9fb855c22b9427112a6e46e6f9261150700ecc752206c36a99398973bc8a10b48587f12bc42bed7d +DIST python-lsp-server-1.0.1.tar.gz 56835 BLAKE2B 430e215b7d65bff2008136783539c262ee201d651bf83750333d41353483882fe7a603208c2725c89530a34cef22e73fe1ef26ec80fe7fb42d2df79eae511528 SHA512 bf116d92bdebea41e4f6647673d390887d84be70d612b92b8c3973aa55db4b151c1188b06fb8e3b6dccb814fd22f938572e998f0b1329bf0b69d0e4750b8f5f6 +EBUILD python-lsp-server-1.0.1.ebuild 2288 BLAKE2B 47f990512d9a5bb3728152f441817400b79e5f32b71cd669b66a5868c9f116776cbd4573fa2f18c8cd41950aee1a25e54179902f3180d3ecd3109c58c7ca22fb SHA512 a97b0540b36eeae3442afd47c1162bef0c8426e71f2d1ae06bedbb95f318283b4206b82280a175dc6e2a257280344cb7e777c0c76f4c589a2038e8a068853f35 +MISC metadata.xml 463 BLAKE2B 4b7c9f0dd4bf6631ed4da34e4c048a5ce16b676b6c56a7f7598074db744e1ccff4c977b5dfcf46d77221d9b1821e56df1722a626f02a6fb7f7c6ba303308c514 SHA512 f868ad2bb319f1ababb0d9a70cb368dec36935822678a6bc365eb2569cab661d300d4d347cd207f6b2f537b5ffebb84dd804fc2faa35cf85f17d437edb177eb7 diff --git a/dev-python/python-lsp-server/files/pyls-fix-test-with-pylint28.patch b/dev-python/python-lsp-server/files/pyls-fix-test-with-pylint28.patch new file mode 100644 index 000000000000..99790b6baed9 --- /dev/null +++ b/dev-python/python-lsp-server/files/pyls-fix-test-with-pylint28.patch @@ -0,0 +1,237 @@ +From f6d9041b81d142657985b696d8da82cebdbe00bb Mon Sep 17 00:00:00 2001 +From: krassowski <krassowski.michal@gmail.com> +Date: Sun, 25 Apr 2021 21:06:28 +0100 +Subject: [PATCH 1/2] Address pylint's "consider-using-with" warnings + +--- + pylsp/plugins/flake8_lint.py | 25 +++++++++++++++---------- + pylsp/plugins/pylint_lint.py | 28 ++++++++++++++++------------ + test/plugins/test_flake8_lint.py | 7 +++---- + test/plugins/test_pylint_lint.py | 7 +++---- + 4 files changed, 37 insertions(+), 30 deletions(-) + +diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py +index d632395..dfee5b4 100644 +--- a/pylsp/plugins/flake8_lint.py ++++ b/pylsp/plugins/flake8_lint.py +@@ -5,6 +5,7 @@ + import logging + import os.path + import re ++from contextlib import ExitStack + from subprocess import Popen, PIPE + from pylsp import hookimpl, lsp + +@@ -65,16 +66,20 @@ def run_flake8(flake8_executable, args, document): + ) + + log.debug("Calling %s with args: '%s'", flake8_executable, args) +- try: +- cmd = [flake8_executable] +- cmd.extend(args) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) +- except IOError: +- log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable) +- cmd = ['python', '-m', 'flake8'] +- cmd.extend(args) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) +- (stdout, stderr) = p.communicate(document.source.encode()) ++ with ExitStack() as stack: ++ try: ++ cmd = [flake8_executable] ++ cmd.extend(args) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ stack.enter_context(p) ++ except IOError: ++ log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable) ++ cmd = ['python', '-m', 'flake8'] ++ cmd.extend(args) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ stack.enter_context(p) ++ # exit stack ensures that even if an exception happens, the process `p` will be properly terminated ++ (stdout, stderr) = p.communicate(document.source.encode()) + if stderr: + log.error("Error while running flake8 '%s'", stderr.decode()) + return stdout.decode() +diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py +index 5491787..6449cda 100644 +--- a/pylsp/plugins/pylint_lint.py ++++ b/pylsp/plugins/pylint_lint.py +@@ -7,6 +7,7 @@ + import logging + import sys + import re ++from contextlib import ExitStack + from subprocess import Popen, PIPE + + from pylint.epylint import py_run +@@ -232,18 +233,21 @@ def _run_pylint_stdio(pylint_executable, document, flags): + :rtype: string + """ + log.debug("Calling %s with args: '%s'", pylint_executable, flags) +- try: +- cmd = [pylint_executable] +- cmd.extend(flags) +- cmd.extend(['--from-stdin', document.path]) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) +- except IOError: +- log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable) +- cmd = ['python', '-m', 'pylint'] +- cmd.extend(flags) +- cmd.extend(['--from-stdin', document.path]) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) +- (stdout, stderr) = p.communicate(document.source.encode()) ++ with ExitStack() as stack: ++ try: ++ cmd = [pylint_executable] ++ cmd.extend(flags) ++ cmd.extend(['--from-stdin', document.path]) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ stack.enter_context(p) ++ except IOError: ++ log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable) ++ cmd = ['python', '-m', 'pylint'] ++ cmd.extend(flags) ++ cmd.extend(['--from-stdin', document.path]) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ stack.enter_context(p) ++ (stdout, stderr) = p.communicate(document.source.encode()) + if stderr: + log.error("Error while running pylint '%s'", stderr.decode()) + return stdout.decode() +diff --git a/test/plugins/test_flake8_lint.py b/test/plugins/test_flake8_lint.py +index eaabd40..4faf0dd 100644 +--- a/test/plugins/test_flake8_lint.py ++++ b/test/plugins/test_flake8_lint.py +@@ -21,10 +21,9 @@ def using_const(): + + + def temp_document(doc_text, workspace): +- temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False) +- name = temp_file.name +- temp_file.write(doc_text) +- temp_file.close() ++ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file: ++ name = temp_file.name ++ temp_file.write(doc_text) + doc = Document(uris.from_fs_path(name), workspace) + + return name, doc +diff --git a/test/plugins/test_pylint_lint.py b/test/plugins/test_pylint_lint.py +index f83e754..cf7a7e4 100644 +--- a/test/plugins/test_pylint_lint.py ++++ b/test/plugins/test_pylint_lint.py +@@ -28,10 +28,9 @@ def hello(): + @contextlib.contextmanager + def temp_document(doc_text, workspace): + try: +- temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False) +- name = temp_file.name +- temp_file.write(doc_text) +- temp_file.close() ++ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file: ++ name = temp_file.name ++ temp_file.write(doc_text) + yield Document(uris.from_fs_path(name), workspace) + finally: + os.remove(name) + +From 2d980b6d99b06de827d6589a48a75c6b196b32f4 Mon Sep 17 00:00:00 2001 +From: krassowski <krassowski.michal@gmail.com> +Date: Sun, 25 Apr 2021 22:14:53 +0100 +Subject: [PATCH 2/2] Revert the use of ExitStack, as requested + +--- + pylsp/plugins/flake8_lint.py | 25 ++++++++++--------------- + pylsp/plugins/pylint_lint.py | 28 ++++++++++++---------------- + 2 files changed, 22 insertions(+), 31 deletions(-) + +diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py +index dfee5b4..03504ef 100644 +--- a/pylsp/plugins/flake8_lint.py ++++ b/pylsp/plugins/flake8_lint.py +@@ -5,7 +5,6 @@ + import logging + import os.path + import re +-from contextlib import ExitStack + from subprocess import Popen, PIPE + from pylsp import hookimpl, lsp + +@@ -66,20 +65,16 @@ def run_flake8(flake8_executable, args, document): + ) + + log.debug("Calling %s with args: '%s'", flake8_executable, args) +- with ExitStack() as stack: +- try: +- cmd = [flake8_executable] +- cmd.extend(args) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with +- stack.enter_context(p) +- except IOError: +- log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable) +- cmd = ['python', '-m', 'flake8'] +- cmd.extend(args) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with +- stack.enter_context(p) +- # exit stack ensures that even if an exception happens, the process `p` will be properly terminated +- (stdout, stderr) = p.communicate(document.source.encode()) ++ try: ++ cmd = [flake8_executable] ++ cmd.extend(args) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ except IOError: ++ log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable) ++ cmd = ['python', '-m', 'flake8'] ++ cmd.extend(args) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ (stdout, stderr) = p.communicate(document.source.encode()) + if stderr: + log.error("Error while running flake8 '%s'", stderr.decode()) + return stdout.decode() +diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py +index 6449cda..d5ff3db 100644 +--- a/pylsp/plugins/pylint_lint.py ++++ b/pylsp/plugins/pylint_lint.py +@@ -7,7 +7,6 @@ + import logging + import sys + import re +-from contextlib import ExitStack + from subprocess import Popen, PIPE + + from pylint.epylint import py_run +@@ -233,21 +232,18 @@ def _run_pylint_stdio(pylint_executable, document, flags): + :rtype: string + """ + log.debug("Calling %s with args: '%s'", pylint_executable, flags) +- with ExitStack() as stack: +- try: +- cmd = [pylint_executable] +- cmd.extend(flags) +- cmd.extend(['--from-stdin', document.path]) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with +- stack.enter_context(p) +- except IOError: +- log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable) +- cmd = ['python', '-m', 'pylint'] +- cmd.extend(flags) +- cmd.extend(['--from-stdin', document.path]) +- p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with +- stack.enter_context(p) +- (stdout, stderr) = p.communicate(document.source.encode()) ++ try: ++ cmd = [pylint_executable] ++ cmd.extend(flags) ++ cmd.extend(['--from-stdin', document.path]) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ except IOError: ++ log.debug("Can't execute %s. Trying with 'python -m pylint'", pylint_executable) ++ cmd = ['python', '-m', 'pylint'] ++ cmd.extend(flags) ++ cmd.extend(['--from-stdin', document.path]) ++ p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with ++ (stdout, stderr) = p.communicate(document.source.encode()) + if stderr: + log.error("Error while running pylint '%s'", stderr.decode()) + return stdout.decode() diff --git a/dev-python/python-lsp-server/metadata.xml b/dev-python/python-lsp-server/metadata.xml new file mode 100644 index 000000000000..d18c2963a96b --- /dev/null +++ b/dev-python/python-lsp-server/metadata.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>andrewammerlaan@gentoo.org</email> + <name>Andrew Ammerlaan</name> + </maintainer> + <maintainer type="project"> + <email>python@gentoo.org</email> + <name>Python</name> + </maintainer> + <stabilize-allarches/> + <upstream> + <remote-id type="pypi">python-lsp-server</remote-id> + </upstream> +</pkgmetadata> diff --git a/dev-python/python-lsp-server/python-lsp-server-1.0.1.ebuild b/dev-python/python-lsp-server/python-lsp-server-1.0.1.ebuild new file mode 100644 index 000000000000..ef8e5c76b266 --- /dev/null +++ b/dev-python/python-lsp-server/python-lsp-server-1.0.1.ebuild @@ -0,0 +1,70 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7..9} ) + +DISTUTILS_USE_SETUPTOOLS=rdepend +inherit distutils-r1 optfeature + +DESCRIPTION="Python Language Server for the Language Server Protocol" +HOMEPAGE="https://github.com/python-lsp/python-lsp-server" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm64 ~x86" + +BDEPEND=" + test? ( + dev-python/autopep8[${PYTHON_USEDEP}] + dev-python/flaky[${PYTHON_USEDEP}] + >=dev-python/flake8-3.8.0[${PYTHON_USEDEP}] + dev-python/matplotlib[${PYTHON_USEDEP}] + >=dev-python/mccabe-0.6.0[${PYTHON_USEDEP}] + <dev-python/mccabe-0.7.0[${PYTHON_USEDEP}] + dev-python/numpy[${PYTHON_USEDEP}] + dev-python/pandas[${PYTHON_USEDEP}] + >=dev-python/pycodestyle-2.7.0[${PYTHON_USEDEP}] + >=dev-python/pydocstyle-2.0.0[${PYTHON_USEDEP}] + >=dev-python/pyflakes-2.3.0[${PYTHON_USEDEP}] + <dev-python/pyflakes-2.4.0[${PYTHON_USEDEP}] + >=dev-python/pylint-2.5.0[${PYTHON_USEDEP}] + dev-python/QtPy[gui,testlib,${PYTHON_USEDEP}] + >=dev-python/rope-0.10.5[${PYTHON_USEDEP}] + dev-python/yapf[${PYTHON_USEDEP}] + )" + +RDEPEND=" + >=dev-python/jedi-0.17.2[${PYTHON_USEDEP}] + <dev-python/jedi-0.19.0[${PYTHON_USEDEP}] + >=dev-python/python-lsp-jsonrpc-1.0.0[${PYTHON_USEDEP}] + dev-python/pluggy[${PYTHON_USEDEP}] + >=dev-python/ujson-3[${PYTHON_USEDEP}] +" + +PATCHES=( + "${FILESDIR}/pyls-fix-test-with-pylint28.patch" +) + +distutils_enable_tests pytest + +python_prepare_all() { + # remove pytest-cov dep + sed -i -e '0,/addopts/I!d' setup.cfg || die + + distutils-r1_python_prepare_all +} + +pkg_postinst() { + optfeature "Automatically formats Python code to conform to the PEP 8 style guide" dev-python/autopep8 + optfeature "A wrapper around PyFlakes, pep8 & mccabe" dev-python/flake8 + optfeature "flake8 plugin: McCabe complexity checker" dev-python/mccabe + optfeature "Python style guide checker (fka pep8)" dev-python/pycodestyle + optfeature "Python docstring style checker" dev-python/pydocstyle + optfeature "Passive checker for Python programs" dev-python/pyflakes + optfeature "Python code static checker" dev-python/pylint + optfeature "Python refactoring library" dev-python/rope + optfeature "A formatter for Python files" dev-python/yapf +} |