Skip to content

Commit

Permalink
Merge pull request #48 from inpefess/maintenance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
inpefess committed Aug 4, 2022
2 parents 5ba99df + 4909494 commit 85b21ca
Show file tree
Hide file tree
Showing 21 changed files with 530 additions and 440 deletions.
12 changes: 5 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,23 @@ jobs:
- save_cache:
paths:
- ./venv
key: v2-dependencies-{{ checksum "poetry.lock" }}
key: v1-dependencies-<< parameters.python_version >>-{{ checksum "poetry.lock" }}
- run:
name: run tests
command: |
. venv/bin/activate
pytest --cov isabelle_client --cov-report xml --cov-fail-under=99\
--junit-xml test-results/isabelle-client.xml isabelle_client
pytest isabelle_client
- run:
name: run linters
command: |
. venv/bin/activate
pycodestyle --max-doc-length 160 --ignore E203,E501,W503\
isabelle_client examples
pylint --rcfile=.pylintrc isabelle_client examples
flake8 isabelle_client examples
pylint isabelle_client examples
- run:
name: run type checks
command: |
. venv/bin/activate
mypy --config-file mypy.ini isabelle_client examples
mypy isabelle_client examples
- run:
name: upload data to codecov
command: |
Expand Down
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ local-build.sh
./**/.toml
cicm2021paper/
LICENSE
tests/
tests/
coverage.xml
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
doctests = True
ignore =
E203,
E501,
W503
per-file-ignores =
isabelle_client/__init__.py:F401
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ doc/build/
.ipynb_checkpoints/
flycheck_*.*
.dir-locals.el
examples/output/
examples/output/
coverage.xml
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ repos:
entry: black
language: system
types: [python]
- id: pycodestyle
name: pycodestyle
entry: pycodestyle --max-doc-length 160 --ignore E203,E501,W503
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
- id: mypy
name: mypy
entry: mypy --config-file mypy.ini
entry: mypy
language: system
types: [python]
- id: pylint
name: pylint
entry: pylint --rcfile=.pylintrc
entry: pylint
language: system
types: [python]
6 changes: 0 additions & 6 deletions .pylintrc

This file was deleted.

17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.10"

sphinx:
configuration: doc/source/conf.py
fail_on_warning: true

python:
install:
- requirements: doc/requirements.txt
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|PyPI version| |Anaconda version| |CircleCI| |Documentation Status| |codecov| |Binder|
|Binder|\ |PyPI version|\ |Anaconda version|\ |CircleCI|\ |Documentation Status|\ |codecov|

Python client for Isabelle server
=================================
Expand Down
4 changes: 2 additions & 2 deletions doc/source/usage-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The client works well in scripts and in Jupyter notebooks. For the latter, one h
Starting Isabelle server
========================

First, we need to start an Isabelle server (doesn't work on Windows)::
First, we need to start an Isabelle server ::
from isabelle_client import start_isabelle_server

Expand All @@ -51,7 +51,7 @@ First, we need to start an Isabelle server (doesn't work on Windows)::

We could also start the server outside this script and use its info (on Windows, this is done in Cygwin)::

isabelle server > server.info
isabelle server

Interacting with Isabelle server
================================
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.5"
__version__ = "0.3.6"
4 changes: 3 additions & 1 deletion isabelle_client/compatibility_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ def async_run(a_coroutine: Coroutine) -> Any:
# pylint: disable=no-member
result = asyncio.run(a_coroutine) # type: ignore
else:
result = asyncio.get_event_loop().run_until_complete(a_coroutine)
result = asyncio.get_event_loop().run_until_complete(
a_coroutine
) # pragma: no cover
return result
2 changes: 1 addition & 1 deletion isabelle_client/isabelle__client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def execute_command(
"""
executes a command and waits for results
>>> logger = getfixture("mock_logger")
>>> logger = getfixture("mock_logger") # noqa: F821
>>> isabelle_client = IsabelleClient(
... "localhost", 9999, "test_password", logger
... )
Expand Down
12 changes: 12 additions & 0 deletions isabelle_client/resources/Cygwin-Isabelle.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off

set TEMP_WINDOWS=%TEMP%
set HOME=%HOMEDRIVE%%HOMEPATH%
set PATH=%ISABELLE_INST_DIR%\bin;%PATH%
set LANG=en_US.UTF-8
set CHERE_INVOKING=true
set arg1=%1
set unquoted_arg1=%arg1:"=%

"%ISABELLE_INST_DIR%\contrib\cygwin\bin\bash" --login -i ^
-c "isabelle %unquoted_arg1%"
2 changes: 1 addition & 1 deletion isabelle_client/socket_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def get_final_message(
'final' type arrives
>>> from isabelle_client.compatibility_helper import async_run
>>> test_logger = getfixture("mock_logger")
>>> test_logger = getfixture("mock_logger") # noqa: F821
>>> async def awaiter():
... test_reader, test_writer = await asyncio.open_connection(
... "localhost", 9999
Expand Down
37 changes: 37 additions & 0 deletions isabelle_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@
A collection of different useful functions.
"""
import asyncio
import os
import re
import sys
from typing import Optional, Tuple

from isabelle_client.compatibility_helper import async_run
from isabelle_client.isabelle__client import IsabelleClient

if sys.version_info.major == 3 and sys.version_info.minor >= 9:
# pylint: disable=no-name-in-module, import-error
from importlib.resources import files # type: ignore
else: # pragma: no cover
from importlib_resources import files # pylint: disable=import-error


def get_isabelle_client(server_info: str) -> IsabelleClient:
"""
Expand Down Expand Up @@ -76,6 +84,8 @@ def start_isabelle_server(
+ (f" -p {str(port)}" if port is not None else "")
+ (f" -n {name}" if name is not None else "")
)
if sys.platform == "win32":
return start_isabelle_server_win32(args) # pragma: no cover

async def async_call():
isabelle_server = await asyncio.create_subprocess_exec(
Expand All @@ -86,3 +96,30 @@ async def async_call():
), isabelle_server

return async_run(async_call())


def start_isabelle_server_win32(
args: str,
) -> Tuple[str, asyncio.subprocess.Process]: # pragma: no cover
"""start Isabelle server on Windows"""
# 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():
isabelle_server = await asyncio.create_subprocess_exec(
str(
files("isabelle_client").joinpath(
os.path.join("resources", "Cygwin-Isabelle.bat")
)
),
args,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
server_info = (await isabelle_server.stdout.readline()).decode("utf-8")
return server_info, isabelle_server

return async_run(async_call())
10 changes: 4 additions & 6 deletions local-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ cd doc
make clean html coverage
cat build/coverage/python.txt
cd ..
pycodestyle --max-doc-length 160 --ignore E203,E501,W503 \
${PACKAGE_NAME} examples
pylint --rcfile=.pylintrc ${PACKAGE_NAME} examples
mypy --config-file mypy.ini ${PACKAGE_NAME} examples
pytest --cov ${PACKAGE_NAME} --cov-report term-missing --cov-fail-under=99 \
--junit-xml test-results/isabelle-client.xml ${PACKAGE_NAME}
flake8 ${PACKAGE_NAME} examples
pylint ${PACKAGE_NAME} examples
mypy ${PACKAGE_NAME} examples
pytest ${PACKAGE_NAME}
scc -i py ${PACKAGE_NAME}
1 change: 0 additions & 1 deletion mypy.ini

This file was deleted.

0 comments on commit 85b21ca

Please sign in to comment.