diff --git a/.github/workflows/packagingtest.yml b/.github/workflows/packagingtest.yml index 592eec6..ce8a0f0 100644 --- a/.github/workflows/packagingtest.yml +++ b/.github/workflows/packagingtest.yml @@ -33,7 +33,7 @@ jobs: run: | pip install flake8 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude benchmark - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark + flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark - name: Packaging run: | python setup.py bdist_wheel diff --git a/buildutils/build.py b/buildutils/build.py index f5d421b..477cbc6 100644 --- a/buildutils/build.py +++ b/buildutils/build.py @@ -7,7 +7,7 @@ import struct import sys -def build_libcapnp(bundle_dir, build_dir): +def build_libcapnp(bundle_dir, build_dir): # noqa: C901 ''' Build capnproto ''' diff --git a/buildutils/bundle.py b/buildutils/bundle.py index a406ef9..f9f7318 100644 --- a/buildutils/bundle.py +++ b/buildutils/bundle.py @@ -11,7 +11,7 @@ # for original project. -import fileinput +import fileinput # noqa import os import shutil import tarfile diff --git a/capnp/_gen.py b/capnp/_gen.py index 5b551ef..81f4723 100644 --- a/capnp/_gen.py +++ b/capnp/_gen.py @@ -6,6 +6,7 @@ from jinja2 import Environment, PackageLoader import capnp import schema_capnp + def find_type(code, id): for node in code['nodes']: if node['id'] == id: diff --git a/docs/conf.py b/docs/conf.py index d5baf33..172b9bd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -144,7 +144,7 @@ html_theme = 'nature' # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html', 'versioning.html'] } +html_sidebars = {'**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html', 'versioning.html']} # Additional templates that should be rendered to pages, maps page names to # template names. diff --git a/examples/async_calculator_server.py b/examples/async_calculator_server.py index b2d7ddc..8b1362c 100755 --- a/examples/async_calculator_server.py +++ b/examples/async_calculator_server.py @@ -32,7 +32,6 @@ class Server: logger.debug("myreader done.") return True - async def mywriter(self): while self.retry: try: @@ -51,7 +50,6 @@ class Server: logger.debug("mywriter done.") return True - async def myserver(self, reader, writer): # Start TwoPartyServer using TwoWayPipe (only requires bootstrap) self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl()) diff --git a/examples/async_server.py b/examples/async_server.py index 067226e..608d2b8 100755 --- a/examples/async_server.py +++ b/examples/async_server.py @@ -45,7 +45,6 @@ class Server: logger.debug("myreader done.") return True - async def mywriter(self): while self.retry: try: @@ -64,7 +63,6 @@ class Server: logger.debug("mywriter done.") return True - async def myserver(self, reader, writer): # Start TwoPartyServer using TwoWayPipe (only requires bootstrap) self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl()) diff --git a/examples/async_ssl_calculator_server.py b/examples/async_ssl_calculator_server.py index e9b276b..9c605ec 100755 --- a/examples/async_ssl_calculator_server.py +++ b/examples/async_ssl_calculator_server.py @@ -36,7 +36,6 @@ class Server: logger.debug("myreader done.") return True - async def mywriter(self): while self.retry: try: @@ -55,7 +54,6 @@ class Server: logger.debug("mywriter done.") return True - async def myserver(self, reader, writer): # Start TwoPartyServer using TwoWayPipe (only requires bootstrap) self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl()) diff --git a/examples/async_ssl_server.py b/examples/async_ssl_server.py index 575d482..91aa996 100755 --- a/examples/async_ssl_server.py +++ b/examples/async_ssl_server.py @@ -52,7 +52,6 @@ class Server: logger.debug("myreader done.") return True - async def mywriter(self): while self.retry: try: @@ -71,7 +70,6 @@ class Server: logger.debug("mywriter done.") return True - async def myserver(self, reader, writer): # Start TwoPartyServer using TwoWayPipe (only requires bootstrap) self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl()) diff --git a/test/test_examples.py b/test/test_examples.py index e77a0a9..adc77b4 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -11,6 +11,7 @@ hostname = 'localhost' processes = [] + @pytest.fixture def cleanup(): yield @@ -18,7 +19,7 @@ def cleanup(): p.kill() -def run_subprocesses(address, server, client, wildcard_server=False, ipv4_force=True): +def run_subprocesses(address, server, client, wildcard_server=False, ipv4_force=True): # noqa server_attempt = 0 server_attempts = 2 done = False @@ -35,7 +36,7 @@ def run_subprocesses(address, server, client, wildcard_server=False, ipv4_force= c_address = '{}:{}'.format(addr, port) s_address = c_address if wildcard_server: - s_address = '*:{}'.format(port) # Use wildcard address for server + s_address = '*:{}'.format(port) # Use wildcard address for server print("Forcing ipv4 -> {} => {} {}".format(address, c_address, s_address)) # Start server @@ -133,7 +134,13 @@ def test_addressbook_example(cleanup): assert ret == 0 -@pytest.mark.skipif(sys.platform == "win32", reason="Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. See https://github.com/capnproto/pycapnp/issues/196") +@pytest.mark.skipif( + sys.platform == "win32", + reason=""" +Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. +See https://github.com/capnproto/pycapnp/issues/196 +""" +) def test_async_example(cleanup): address = '{}:36434'.format(hostname) server = 'async_server.py' @@ -141,7 +148,13 @@ def test_async_example(cleanup): run_subprocesses(address, server, client) -@pytest.mark.skipif(sys.platform == "win32", reason="Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. See https://github.com/capnproto/pycapnp/issues/196") +@pytest.mark.skipif( + sys.platform == "win32", + reason=""" +Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. +See https://github.com/capnproto/pycapnp/issues/196 +""" +) def test_ssl_async_example(cleanup): address = '{}:36435'.format(hostname) server = 'async_ssl_server.py' @@ -149,7 +162,13 @@ def test_ssl_async_example(cleanup): run_subprocesses(address, server, client, ipv4_force=False) -@pytest.mark.skipif(sys.platform == "win32", reason="Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. See https://github.com/capnproto/pycapnp/issues/196") +@pytest.mark.skipif( + sys.platform == "win32", + reason=""" +Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop. +See https://github.com/capnproto/pycapnp/issues/196 +""" +) def test_ssl_reconnecting_async_example(cleanup): address = '{}:36436'.format(hostname) server = 'async_ssl_server.py' diff --git a/test/test_load.py b/test/test_load.py index fba97fc..605d579 100644 --- a/test/test_load.py +++ b/test/test_load.py @@ -116,4 +116,4 @@ def test_remove_import_hook(): def test_bundled_import_hook(): # stream.capnp should be bundled, or provided by the system capnproto capnp.add_import_hook() - import stream_capnp + import stream_capnp # noqa: F401 diff --git a/test/test_rpc.py b/test/test_rpc.py index 92e5df9..ba1c5e8 100644 --- a/test/test_rpc.py +++ b/test/test_rpc.py @@ -32,6 +32,7 @@ def test_simple_rpc_with_options(): remote = cap.foo(i=5) _ = remote.wait() + def test_simple_rpc_bootstrap(): read, write = socket.socketpair() diff --git a/test/test_rpc_calculator.py b/test/test_rpc_calculator.py index b834624..7f8980d 100644 --- a/test/test_rpc_calculator.py +++ b/test/test_rpc_calculator.py @@ -2,9 +2,7 @@ import gc import os import pytest import socket -import subprocess import sys # add examples dir to sys.path -import time import capnp @@ -15,10 +13,11 @@ import calculator_client # noqa: E402 import calculator_server # noqa: E402 # Uses run_subprocesses function -import test_examples +import test_examples # noqa: E402 processes = [] + @pytest.fixture def cleanup(): yield diff --git a/test/test_serialization.py b/test/test_serialization.py index c9bcd89..ad8f5ec 100644 --- a/test/test_serialization.py +++ b/test/test_serialization.py @@ -106,6 +106,7 @@ def test_roundtrip_bytes_packed(all_types): msg = all_types.TestAllTypes.from_bytes_packed(message_bytes) test_regression.check_all_types(msg) + @contextmanager def _warnings(expected_count=2, expected_text='This message has already been written once.'): with warnings.catch_warnings(record=True) as w: @@ -115,6 +116,7 @@ def _warnings(expected_count=2, expected_text='This message has already been wri assert all(issubclass(x.category, UserWarning) for x in w), w assert all(expected_text in str(x.message) for x in w), w + def test_roundtrip_file_multiple(all_types): f = tempfile.TemporaryFile() msg = all_types.TestAllTypes.new_message()