Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 27, 2023
1 parent be4da42 commit 9a6777a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ async def server_exit(self, server: asyncio.subprocess.Process):

# 0: all good
# -15: terminated
if server.returncode not in { 0, -15 }:
self.logger.error(f"sphinx-agent process exited with code: {server.returncode}")
if server.returncode not in {0, -15}:
self.logger.error(
f"sphinx-agent process exited with code: {server.returncode}"
)

if server.stderr is not None:
stderr = await server.stderr.read()
Expand Down
17 changes: 7 additions & 10 deletions lib/esbonio/esbonio/sphinx_agent/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import sys
import typing
from functools import partial
from typing import IO
from typing import Callable
from typing import Dict
from typing import IO
from typing import List
from typing import Optional
from typing import Tuple
Expand All @@ -28,7 +28,6 @@
from .util import send_error
from .util import send_message


STATIC_DIR = (pathlib.Path(__file__).parent / "static").resolve()


Expand Down Expand Up @@ -89,17 +88,17 @@ class definition from the ``types`` module.

for name in dir(self):
method_func = getattr(self, name)
if name.startswith('_') or not inspect.ismethod(method_func):
if name.startswith("_") or not inspect.ismethod(method_func):
continue

parameters = inspect.signature(method_func).parameters
if set(parameters.keys()) != {'request'}:
if set(parameters.keys()) != {"request"}:
continue

request_type = typing.get_type_hints(method_func)['request']
if not all([
hasattr(request_type, 'jsonrpc'), hasattr(request_type, 'method')
]):
request_type = typing.get_type_hints(method_func)["request"]
if not all(
[hasattr(request_type, "jsonrpc"), hasattr(request_type, "method")]
):
continue

handlers[request_type.method] = (request_type, method_func)
Expand Down Expand Up @@ -139,7 +138,6 @@ def create_sphinx_app(self, request: types.CreateApplicationRequest):
)
send_message(response)


def _cb_env_before_read_docs(self, app: Sphinx, env, docnames: List[str]):
"""Used to add additional documents to the "to build" list."""

Expand Down Expand Up @@ -207,7 +205,6 @@ def build_sphinx_app(self, request: types.BuildRequest):
except Exception:
send_error(id=request.id, code=-32602, message="Sphinx build failed.")


def notify_exit(self, request: types.ExitNotification):
"""Sent from the client to signal that the agent should exit."""
sys.exit(0)
Expand Down
1 change: 0 additions & 1 deletion lib/esbonio/esbonio/sphinx_agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .handlers import SphinxHandler
from .util import send_error


HANDLERS = SphinxHandler()
logger = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion lib/esbonio/esbonio/sphinx_agent/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class ExitNotification:
jsonrpc: str = dataclasses.field(default="2.0")



METHOD_TO_MESSAGE_TYPE = {
BuildRequest.method: BuildRequest,
ExitNotification.method: ExitNotification,
Expand Down
5 changes: 3 additions & 2 deletions lib/esbonio/tests/sphinx-agent/test_sa_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from esbonio.server import Uri
from esbonio.server.features.sphinx_manager.client_subprocess import (
SubprocessSphinxClient,
)
from esbonio.server.features.sphinx_manager.client_subprocess import (
make_test_sphinx_client,
)
from esbonio.server.features.sphinx_manager.config import SphinxConfig
Expand All @@ -24,7 +26,6 @@
),
)
async def client(sphinx_client: SubprocessSphinxClient, uri_for, tmp_path_factory):

build_dir = tmp_path_factory.mktemp("build")
test_uri = uri_for("sphinx-default", "workspace", "index.rst")
sd_workspace = uri_for("sphinx-default", "workspace")
Expand All @@ -41,7 +42,7 @@ async def client(sphinx_client: SubprocessSphinxClient, uri_for, tmp_path_factor
"-M",
"html",
sd_workspace.fs_path,
str(build_dir)
str(build_dir),
],
)
resolved = config.resolve(test_uri, workspace, sphinx_client.logger)
Expand Down
3 changes: 2 additions & 1 deletion lib/esbonio/tests/sphinx-agent/test_sa_create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from esbonio.server.features.sphinx_manager.client_subprocess import (
SubprocessSphinxClient,
)
from esbonio.server.features.sphinx_manager.client_subprocess import (
make_test_sphinx_client,
)
from esbonio.server.features.sphinx_manager.config import SphinxConfig
Expand All @@ -25,7 +27,6 @@ async def client(sphinx_client: SubprocessSphinxClient):
yield



@pytest.mark.asyncio
async def test_create_application(client: SubprocessSphinxClient, uri_for):
"""Ensure that we can create a Sphinx application instance correctly."""
Expand Down

0 comments on commit 9a6777a

Please sign in to comment.