diff --git a/.gitignore b/.gitignore index f117763..dfd8b34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.coverage .env .tox *.pyc diff --git a/lib/lsp-devtools/lsp_devtools/agent/client.py b/lib/lsp-devtools/lsp_devtools/agent/client.py index 5fccd28..e91d916 100644 --- a/lib/lsp-devtools/lsp_devtools/agent/client.py +++ b/lib/lsp-devtools/lsp_devtools/agent/client.py @@ -6,26 +6,27 @@ from pygls.client import Client from pygls.client import aio_readline from pygls.protocol import default_converter -from websockets.client import WebSocketClientProtocol from lsp_devtools.agent.protocol import AgentProtocol +# from websockets.client import WebSocketClientProtocol -class WebSocketClientTransportAdapter: - """Protocol adapter for the WebSocket client interface.""" - def __init__(self, ws: WebSocketClientProtocol, loop: asyncio.AbstractEventLoop): - self._ws = ws - self._loop = loop +# class WebSocketClientTransportAdapter: +# """Protocol adapter for the WebSocket client interface.""" - def close(self) -> None: - """Stop the WebSocket server.""" - print("-- CLOSING --") - self._loop.create_task(self._ws.close()) +# def __init__(self, ws: WebSocketClientProtocol, loop: asyncio.AbstractEventLoop): +# self._ws = ws +# self._loop = loop - def write(self, data: Any) -> None: - """Create a task to write specified data into a WebSocket.""" - asyncio.ensure_future(self._ws.send(data)) +# def close(self) -> None: +# """Stop the WebSocket server.""" +# print("-- CLOSING --") +# self._loop.create_task(self._ws.close()) + +# def write(self, data: Any) -> None: +# """Create a task to write specified data into a WebSocket.""" +# asyncio.ensure_future(self._ws.send(data)) class AgentClient(Client): diff --git a/lib/lsp-devtools/lsp_devtools/record/formatters.py b/lib/lsp-devtools/lsp_devtools/record/formatters.py index 0a9ee48..d8cb5cb 100644 --- a/lib/lsp-devtools/lsp_devtools/record/formatters.py +++ b/lib/lsp-devtools/lsp_devtools/record/formatters.py @@ -155,7 +155,7 @@ class FormatString: VARIABLE = re.compile(r"{\.([^}]+)}") def __init__(self, pattern: str): - self.pattern = pattern.replace("\\n", "\n").replace("\\t", "\t") + self.pattern = pattern # .replace("\\n", "\n").replace("\\t", "\t") self._parse() def _parse(self): diff --git a/lib/lsp-devtools/pyproject.toml b/lib/lsp-devtools/pyproject.toml index 8677817..7bd8185 100644 --- a/lib/lsp-devtools/pyproject.toml +++ b/lib/lsp-devtools/pyproject.toml @@ -42,10 +42,6 @@ dev = [ "pre-commit", "tox", ] -test=[ - "pytest-cov", - "pytest-timeout", -] typecheck=[ "mypy", "importlib_resources", @@ -60,6 +56,14 @@ lsp-devtools = "lsp_devtools.cli:main" [tool.setuptools.packages.find] include = ["lsp_devtools*"] +[tool.coverage.run] +source_pkgs = ["lsp_devtools"] + +[tool.coverage.report] +show_missing = true +skip_covered = true +sort = "Cover" + [tool.isort] force_single_line = true profile = "black" @@ -100,16 +104,3 @@ showcontent = true directory = "misc" name = "Misc" showcontent = true - -[tool.tox] -legacy_tox_ini = """ -[tox] -isolated_build = True -skip_missing_interpreters = true -envlist = py{37,38,39,310,311} - -[testenv] -extras=test -commands = - pytest {posargs} -""" diff --git a/lib/lsp-devtools/tests/record/test_formatters.py b/lib/lsp-devtools/tests/record/test_formatters.py index d6e6ca7..c6f7066 100644 --- a/lib/lsp-devtools/tests/record/test_formatters.py +++ b/lib/lsp-devtools/tests/record/test_formatters.py @@ -27,7 +27,7 @@ "textDocument": {"uri": "file:///path/to/file.txt"}, }, }, - "textDocument/completion file:///path/to/file.txt:{'line': 1, 'character': 2}", # noqa: E501 + 'textDocument/completion file:///path/to/file.txt:{\n "line": 1,\n "character": 2\n}', # noqa: E501 ), ( "{.method} {.params.textDocument.uri}:{.params.position|Position}", @@ -61,7 +61,7 @@ "items": [{"label": "one"}, {"label": "two"}, {"label": "three"}] } }, - "{'label': 'one'}\n{'label': 'two'}\n{'label': 'three'}", + '{\n "label": "one"\n}\n{\n "label": "two"\n}\n{\n "label": "three"\n}', ), ( "{.result.items[].label}", @@ -88,7 +88,7 @@ "items": [{"label": "one"}, {"label": "two"}, {"label": "three"}] } }, - "{'label': 'one'}", + '{\n "label": "one"\n}', ), ( "{.result.items[-1]}", @@ -97,7 +97,7 @@ "items": [{"label": "one"}, {"label": "two"}, {"label": "three"}] } }, - "{'label': 'three'}", + '{\n "label": "three"\n}', ), ( "- {.result.items[0].label}", diff --git a/lib/lsp-devtools/tox.ini b/lib/lsp-devtools/tox.ini new file mode 100644 index 0000000..223b1c1 --- /dev/null +++ b/lib/lsp-devtools/tox.ini @@ -0,0 +1,21 @@ +[tox] +isolated_build = True +skip_missing_interpreters = true +min_version = 4.0 +envlist = py{38,39,310,311} + +[testenv] +description = "Run lsp-devtools' test suite" +package = wheel +wheel_build_env = .pkg +deps = + coverage[toml] + pytest + + git+https://github.com/openlawlibrary/pygls +commands_pre = + coverage erase +commands = + coverage run -m pytest {posargs} +commands_post = + coverage report