From f3c11af6fecf53fd67000471b0618a84cf92a7e5 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Tue, 16 Jul 2024 13:49:48 +0200 Subject: [PATCH 1/3] Drop ujson and switch to orjson --- pylsp/__main__.py | 6 +----- pylsp/plugins/pylint_lint.py | 4 ++-- pylsp/python_lsp.py | 4 ++-- pyproject.toml | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pylsp/__main__.py b/pylsp/__main__.py index 44aa3cfa..b0908eaf 100644 --- a/pylsp/__main__.py +++ b/pylsp/__main__.py @@ -2,16 +2,12 @@ # Copyright 2021- Python Language Server Contributors. import argparse +import json import logging import logging.config import sys import time -try: - import ujson as json -except Exception: - import json - from ._version import __version__ from .python_lsp import ( PythonLSPServer, diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py index beffe6f3..ababff3b 100644 --- a/pylsp/plugins/pylint_lint.py +++ b/pylsp/plugins/pylint_lint.py @@ -15,8 +15,8 @@ from pylsp import hookimpl, lsp try: - import ujson as json -except Exception: + import orjson as json +except ImportError: import json log = logging.getLogger(__name__) diff --git a/pylsp/python_lsp.py b/pylsp/python_lsp.py index ba41d6aa..120d29ae 100644 --- a/pylsp/python_lsp.py +++ b/pylsp/python_lsp.py @@ -10,8 +10,8 @@ from typing import Any, Dict, List try: - import ujson as json -except Exception: + import orjson as json +except ImportError: import json from pylsp_jsonrpc.dispatchers import MethodDispatcher diff --git a/pyproject.toml b/pyproject.toml index f9c6a521..0a782d8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "jedi>=0.17.2,<0.20.0", "pluggy>=1.0.0", "python-lsp-jsonrpc>=1.1.0,<2.0.0", - "ujson>=3.0.0", + "orjson>=3.10.0", ] dynamic = ["version"] From 6e1d5c64031c90923d97a0b7dabf8983cb26e230 Mon Sep 17 00:00:00 2001 From: valrus Date: Sat, 17 Aug 2024 13:18:18 -0700 Subject: [PATCH 2/3] Update jsonrpc dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0a782d8d..491d4ef0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = [ "importlib_metadata>=4.8.3;python_version<\"3.10\"", "jedi>=0.17.2,<0.20.0", "pluggy>=1.0.0", - "python-lsp-jsonrpc>=1.1.0,<2.0.0", + "python-lsp-jsonrpc @ git+ssh://git@github.com/valrus/python-lsp-jsonrpc#replace-ujson-with-orjson", "orjson>=3.10.0", ] dynamic = ["version"] From 7084ed8597c3640023c8eed7544c58772fff10df Mon Sep 17 00:00:00 2001 From: valrus Date: Sat, 17 Aug 2024 15:46:58 -0700 Subject: [PATCH 3/3] need to use https for dep, of course --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 491d4ef0..5da5b0f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = [ "importlib_metadata>=4.8.3;python_version<\"3.10\"", "jedi>=0.17.2,<0.20.0", "pluggy>=1.0.0", - "python-lsp-jsonrpc @ git+ssh://git@github.com/valrus/python-lsp-jsonrpc#replace-ujson-with-orjson", + "python-lsp-jsonrpc @ git+https://github.com/valrus/python-lsp-jsonrpc#egg=replace-ujson-with-orjson", "orjson>=3.10.0", ] dynamic = ["version"]