Skip to content

Commit

Permalink
Merge pull request #60 from inpefess/maintenance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
inpefess committed Feb 27, 2023
2 parents 9f416dd + 0cf2b69 commit 57f33eb
Show file tree
Hide file tree
Showing 9 changed files with 695 additions and 278 deletions.
4 changes: 0 additions & 4 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[flake8]
doctests = True
ignore =
E203,
E501,
W503
per-file-ignores =
isabelle_client/__init__.py:F401
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

sys.path.insert(0, os.path.abspath("../.."))
project = "isabelle-client"
version = "0.3.13"
version = "0.3.14"
copyright = "2021-2022, Boris Shminke"
author = "Boris Shminke"
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage"]
Expand Down
2 changes: 1 addition & 1 deletion isabelle_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
from isabelle_client.socket_communication import IsabelleResponse
from isabelle_client.utils import get_isabelle_client, start_isabelle_server

__version__ = "0.3.13"
__version__ = "0.3.14"
14 changes: 9 additions & 5 deletions isabelle_client/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class ReusableTCPServer(socketserver.TCPServer):


@fixture(autouse=True, scope="session")
def tcp_servers() -> Generator[
Tuple[ReusableTCPServer, ReusableTCPServer], None, None
]:
def tcp_servers() -> (
Generator[Tuple[ReusableTCPServer, ReusableTCPServer], None, None]
):
"""
Get a simplistic TCP server mocking Isabelle server behaviour.
Expand All @@ -93,8 +93,12 @@ def tcp_servers() -> Generator[


@fixture
def mock_logger():
"""Get a mock for logger to spy on ``info`` calls."""
def mock_logger() -> Mock:
"""
Get a mock for logger to spy on ``info`` calls.
:returns: mock logger
"""
logger = Mock()
logger.info = Mock()
return logger
8 changes: 6 additions & 2 deletions isabelle_client/socket_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class IsabelleResponse:
response_body: str
response_length: Optional[int] = None

def __str__(self):
"""Pretty print Isabelle server response."""
def __str__(self) -> str:
"""
Pretty print Isabelle server response.
:returns: a string representation of Isabelle server response
"""
return (
(
f"{self.response_length}\n"
Expand Down
35 changes: 28 additions & 7 deletions isabelle_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,23 @@ def start_isabelle_server(
if sys.platform == "win32":
return start_isabelle_server_win32(args) # pragma: no cover

async def async_call():
async def async_call() -> Tuple[str, asyncio.subprocess.Process]:
"""
Start Isabelle server asynchronously.
:returns: a line of server info and server process
:raises ValueError: if no stdout seen after starting the server
"""
isabelle_server = await asyncio.create_subprocess_exec(
"isabelle", *(args.split(" ")), stdout=asyncio.subprocess.PIPE
)
return (await isabelle_server.stdout.readline()).decode(
"utf-8"
), isabelle_server
if isabelle_server.stdout is not None:
return (await isabelle_server.stdout.readline()).decode(
"utf-8"
), isabelle_server
raise ValueError(
"No stdout while startnig the server."
) # pragma: no cover

return asyncio.run(async_call())

Expand All @@ -106,14 +116,21 @@ def start_isabelle_server_win32(
Start Isabelle server on Windows.
:param args: Isabelle server arguments string
:returns: a line of server info and server process
"""
# this line enables asyncio.create_subprocess_exec on Windows:
# https://docs.python.org/3/library/asyncio-platforms.html#asyncio-windows-subprocess
asyncio.set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy() # type: ignore
)

async def async_call():
async def async_call() -> Tuple[str, asyncio.subprocess.Process]:
"""
Start Isabelle server in Cygwin asynchronously.
:returns: a line of server info and server process
:raises ValueError: if no stdout seen after starting the server
"""
isabelle_server = await asyncio.create_subprocess_exec(
str(
files("isabelle_client").joinpath(
Expand All @@ -124,7 +141,11 @@ async def async_call():
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
server_info = (await isabelle_server.stdout.readline()).decode("utf-8")
return server_info, isabelle_server
if isabelle_server.stdout is not None:
server_info = (await isabelle_server.stdout.readline()).decode(
"utf-8"
)
return server_info, isabelle_server
raise ValueError("No stdout while startnig the server.")

return asyncio.run(async_call())
900 changes: 645 additions & 255 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "isabelle-client"
version = "0.3.13"
version = "0.3.14"
description = "A client to Isabelle proof assistant server"
authors = ["Boris Shminke <boris@shminke.ml>"]
license = "Apache-2.0"
Expand Down Expand Up @@ -80,7 +80,7 @@ load-plugins = [
[tool.pylint.parameter_documentation]
accept-no-param-doc = false
accept-no-raise-doc = false
accept-no-return-doc = true
accept-no-return-doc = false
accept-no-yields-doc = false
default-docstring-type = "sphinx"

Expand Down Expand Up @@ -133,7 +133,7 @@ commands =
github_url = "https://github.com/inpfess/isabelle-client/"

[tool.tbump.version]
current = "0.3.13"
current = "0.3.14"
regex = '''
(?P<major>\d+)
\.
Expand Down
2 changes: 2 additions & 0 deletions spelling.dict
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Traceback
os
args
isabelle
Cygwin
stdout

0 comments on commit 57f33eb

Please sign in to comment.