Skip to content

Commit

Permalink
Merge pull request #49 from inpefess/drop-python3.6
Browse files Browse the repository at this point in the history
drop python 3.6 support
  • Loading branch information
inpefess committed Aug 24, 2022
2 parents 85b21ca + 37b044a commit 84e11cf
Show file tree
Hide file tree
Showing 19 changed files with 1,199 additions and 837 deletions.
54 changes: 10 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
version: 2.1

jobs:
build-and-test:
parameters:
python_version:
description: "Python version to test against"
default: "3.10.4"
type: string
docker:
- image: cimg/python:<< parameters.python_version >>
working_directory: ~/repo
- image: inpefess/multipython
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-<< parameters.python_version >>-{{ checksum "poetry.lock" }}
- run:
name: install dependencies
name: install libenchant
command: |
python -m venv venv
. venv/bin/activate
pip install -U pip poetry
poetry install
- save_cache:
paths:
- ./venv
key: v1-dependencies-<< parameters.python_version >>-{{ checksum "poetry.lock" }}
sudo apt-get update
sudo apt-get install -y libenchant-2-2
- run:
name: run tests
name: use tox
command: |
. venv/bin/activate
pytest isabelle_client
- run:
name: run linters
command: |
. venv/bin/activate
flake8 isabelle_client examples
pylint isabelle_client examples
- run:
name: run type checks
command: |
. venv/bin/activate
mypy isabelle_client examples
pip install tox
pyenv local 3.7.13 3.8.13 3.9.13 3.10.4
tox
- run:
name: upload data to codecov
command: |
Expand All @@ -50,15 +24,7 @@ jobs:
path: build
- store_test_results:
path: test-results

workflows:
workflow:
main:
jobs:
- build-and-test:
python_version: "3.7.13"
- build-and-test:
python_version: "3.8.13"
- build-and-test:
python_version: "3.9.12"
- build-and-test:
python_version: "3.10.4"
- build-and-test
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ repos:
entry: pylint
language: system
types: [python]
- id: pydocstyle
name: pydocstyle
entry: pydocstyle
language: system
types: [python]
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ are welcome. To start:
git clone https://github.com/inpefess/isabelle-client
cd isabelle-client
# activate python virtual environment with Python 3.6+
# activate python virtual environment with Python 3.7+
pip install -U pip
pip install -U setuptools wheel poetry
poetry install
Expand Down Expand Up @@ -82,7 +82,7 @@ More documentation can be found
Video example
=============

.. image:: ../../examples/tty.gif
.. image:: ../_static/tty.gif
:alt:

(if not displayed correctly on this page, please watch `here <https://isabelle-client.readthedocs.io/en/latest/#video-example>`__).
Expand Down
File renamed without changes
2 changes: 2 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable-all
"""Sphinx doc config."""
import os
import sys

sys.path.insert(0, os.path.abspath("../.."))
project = "isabelle-client"
version = "0.3.7"
copyright = "2021-2022, Boris Shminke"
author = "Boris Shminke"
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage"]
Expand Down
2 changes: 0 additions & 2 deletions doc/source/package-documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ Package Documentation
:members:
.. automodule:: isabelle_client.socket_communication
:members:
.. automodule:: isabelle_client.compatibility_helper
:members:
.. automodule:: isabelle_client.utils
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,25 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" A scipt for generating the video example """
# noqa: D205
"""A script for generating the video example."""
import os
import sys
import time

with open("video_example/example.txt", "r", encoding="utf-8") as example:
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

with open( # type: ignore
files("isabelle_client").joinpath(
os.path.join("resources", "example.txt")
),
"r",
encoding="utf-8",
) as example:
lines = example.readlines()

for line in lines:
Expand Down
14 changes: 6 additions & 8 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" An example of the client usage """
# noqa: D205
"""An example of the client usage."""
import asyncio
import logging

from isabelle_client import (
async_run,
get_isabelle_client,
start_isabelle_server,
)
from isabelle_client import get_isabelle_client, start_isabelle_server


def main():
""" using Isabelle client """
"""Use Isabelle client."""
# first, we start Isabelle server
server_info, _ = start_isabelle_server(
name="test", port=9999, log_file="server.log"
Expand All @@ -40,7 +38,7 @@ def main():
# or we can build a session document using ROOT and root.tex files from it
isabelle.session_build(dirs=["."], session="examples")
# or we can issue a free-text command through TCP
async_run(isabelle.execute_command("echo 42", asynchronous=False))
asyncio.run(isabelle.execute_command("echo 42", asynchronous=False))
isabelle.shutdown()


Expand Down
6 changes: 3 additions & 3 deletions isabelle_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" A Python client to `Isabelle <https://isabelle.in.tum.de>`__ server """
from isabelle_client.compatibility_helper import async_run
# noqa: D205
"""A Python client to `Isabelle <https://isabelle.in.tum.de>`__ server."""
from isabelle_client.isabelle__client import IsabelleClient
from isabelle_client.socket_communication import IsabelleResponse
from isabelle_client.utils import get_isabelle_client, start_isabelle_server

__version__ = "0.3.6"
__version__ = "0.3.7"
41 changes: 0 additions & 41 deletions isabelle_client/compatibility_helper.py

This file was deleted.

24 changes: 17 additions & 7 deletions isabelle_client/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Fixtures for unit tests live here """
# noqa: D205
"""Fixtures for unit tests live here."""
import socketserver
import threading
from typing import Generator, Tuple
from unittest.mock import Mock

from pytest import fixture


class BuggyTCPHandler(socketserver.BaseRequestHandler):
"""a dummy handler to mock bugs in Isabelle server response"""
"""A dummy handler to mock bugs in Isabelle server response."""

def handle(self):
"""Return something weird."""
request = self.request.recv(1024).decode("utf-8").split("\n")[0]
if request == "ping":
self.request.sendall(b"5\n")
Expand All @@ -34,10 +37,11 @@ def handle(self):


class DummyTCPHandler(socketserver.BaseRequestHandler):
"""a dummy handler to mock Isabelle server"""
"""A dummy handler to mock Isabelle server."""

# pylint: disable=too-many-statements
def handle(self):
"""Return something similar to what Isabelle server does."""
request = self.request.recv(1024).decode("utf-8").split("\n")[1]
command = request.split(" ")[0]
self.request.sendall(b'OK "connection OK"\n')
Expand All @@ -60,14 +64,20 @@ def handle(self):


class ReusableTCPServer(socketserver.TCPServer):
"""ignore TIME-WAIT during testing"""
"""Ignore TIME-WAIT during testing."""

allow_reuse_address = True


@fixture(autouse=True, scope="session")
def tcp_servers():
"""a simplistic TCP server mocking Isabelle server behaviour"""
def tcp_servers() -> Generator[
Tuple[ReusableTCPServer, ReusableTCPServer], None, None
]:
"""
Get a simplistic TCP server mocking Isabelle server behaviour.
:returns: an instance of a mock working server and a mock buggy server
"""
with ReusableTCPServer(
("localhost", 9999), DummyTCPHandler
) as server, ReusableTCPServer(
Expand All @@ -84,7 +94,7 @@ def tcp_servers():

@fixture
def mock_logger():
"""a mock for logger to spy on ``info`` calls"""
"""Get a mock for logger to spy on ``info`` calls."""
logger = Mock()
logger.info = Mock()
return logger

0 comments on commit 84e11cf

Please sign in to comment.