From dc94bc3c7fb1eac91fd40a0b1840004bb13a7048 Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Wed, 29 May 2024 21:12:42 +0100 Subject: [PATCH] chore: fix lints --- docs/source/conf.py | 13 ++++++------- docs/source/ext/examples.py | 11 +++++------ examples/hello-world/main.py | 2 ++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index a79ba0c0..8741c3a4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,15 +12,16 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os -import sys -sys.path.insert(0, os.path.abspath('./ext')) - import importlib.metadata +import os import pathlib import re +import sys + from docutils import nodes +sys.path.insert(0, os.path.abspath("./ext")) + # -- Project information ----------------------------------------------------- @@ -249,9 +250,7 @@ def process_docstring(app, what, name, obj, options, lines): start, end = match.span() item = match.group(1) - lines[i] = "".join( - [line[:start], f":class:`~lsprotocol.types.{item}`", line[end:]] - ) + lines[i] = "".join([line[:start], f":class:`~lsprotocol.types.{item}`", line[end:]]) if (match := MD_LINK_PATTERN.search(line)) is not None: start, end = match.span() diff --git a/docs/source/ext/examples.py b/docs/source/ext/examples.py index df1fa438..39da94ec 100644 --- a/docs/source/ext/examples.py +++ b/docs/source/ext/examples.py @@ -1,12 +1,12 @@ """Documentation for the example servers""" + from __future__ import annotations +import importlib.util as imutil import os import pathlib import typing -import importlib.util as imutil -from docutils import nodes from docutils.parsers.rst import directives from sphinx.util.docutils import SphinxDirective from sphinx.util.logging import getLogger @@ -16,6 +16,7 @@ logger = getLogger(__name__) + class ExampleServerDirective(SphinxDirective): """Automate the process of documenting example servers. @@ -74,13 +75,11 @@ def run(self): # Confusingly, these are processed in reverse order... self.state_machine.insert_input(content, "") - self.state_machine.insert_input( - self.get_docstring(filename), str(filename) - ) + self.state_machine.insert_input(self.get_docstring(filename), str(filename)) return [] def setup(app: Sphinx): - app.add_config_value("example_server_dir", "", rebuild='env') + app.add_config_value("example_server_dir", "", rebuild="env") app.add_directive("example-server", ExampleServerDirective) diff --git a/examples/hello-world/main.py b/examples/hello-world/main.py index 0599ebf9..340e5611 100644 --- a/examples/hello-world/main.py +++ b/examples/hello-world/main.py @@ -3,6 +3,7 @@ server = LanguageServer("example-server", "v0.1") + @server.feature( types.TEXT_DOCUMENT_COMPLETION, types.CompletionOptions(trigger_characters=["."]), @@ -19,5 +20,6 @@ def completions(params: types.CompletionParams): types.CompletionItem(label="friend"), ] + if __name__ == "__main__": server.start_io()