Fixing flake8 linting errors
- Enabling builds to fail on simple lint failures now
This commit is contained in:
2
.github/workflows/packagingtest.yml
vendored
2
.github/workflows/packagingtest.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pip install flake8
|
pip install flake8
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude benchmark
|
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
|
- name: Packaging
|
||||||
run: |
|
run: |
|
||||||
python setup.py bdist_wheel
|
python setup.py bdist_wheel
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import struct
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def build_libcapnp(bundle_dir, build_dir):
|
def build_libcapnp(bundle_dir, build_dir): # noqa: C901
|
||||||
'''
|
'''
|
||||||
Build capnproto
|
Build capnproto
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# for original project.
|
# for original project.
|
||||||
|
|
||||||
|
|
||||||
import fileinput
|
import fileinput # noqa
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from jinja2 import Environment, PackageLoader
|
|||||||
import capnp
|
import capnp
|
||||||
import schema_capnp
|
import schema_capnp
|
||||||
|
|
||||||
|
|
||||||
def find_type(code, id):
|
def find_type(code, id):
|
||||||
for node in code['nodes']:
|
for node in code['nodes']:
|
||||||
if node['id'] == id:
|
if node['id'] == id:
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ html_theme = 'nature'
|
|||||||
# html_use_smartypants = True
|
# html_use_smartypants = True
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# 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
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
# template names.
|
# template names.
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class Server:
|
|||||||
logger.debug("myreader done.")
|
logger.debug("myreader done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def mywriter(self):
|
async def mywriter(self):
|
||||||
while self.retry:
|
while self.retry:
|
||||||
try:
|
try:
|
||||||
@@ -51,7 +50,6 @@ class Server:
|
|||||||
logger.debug("mywriter done.")
|
logger.debug("mywriter done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def myserver(self, reader, writer):
|
async def myserver(self, reader, writer):
|
||||||
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
||||||
self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl())
|
self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl())
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class Server:
|
|||||||
logger.debug("myreader done.")
|
logger.debug("myreader done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def mywriter(self):
|
async def mywriter(self):
|
||||||
while self.retry:
|
while self.retry:
|
||||||
try:
|
try:
|
||||||
@@ -64,7 +63,6 @@ class Server:
|
|||||||
logger.debug("mywriter done.")
|
logger.debug("mywriter done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def myserver(self, reader, writer):
|
async def myserver(self, reader, writer):
|
||||||
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
||||||
self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl())
|
self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl())
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class Server:
|
|||||||
logger.debug("myreader done.")
|
logger.debug("myreader done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def mywriter(self):
|
async def mywriter(self):
|
||||||
while self.retry:
|
while self.retry:
|
||||||
try:
|
try:
|
||||||
@@ -55,7 +54,6 @@ class Server:
|
|||||||
logger.debug("mywriter done.")
|
logger.debug("mywriter done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def myserver(self, reader, writer):
|
async def myserver(self, reader, writer):
|
||||||
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
||||||
self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl())
|
self.server = capnp.TwoPartyServer(bootstrap=CalculatorImpl())
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class Server:
|
|||||||
logger.debug("myreader done.")
|
logger.debug("myreader done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def mywriter(self):
|
async def mywriter(self):
|
||||||
while self.retry:
|
while self.retry:
|
||||||
try:
|
try:
|
||||||
@@ -71,7 +70,6 @@ class Server:
|
|||||||
logger.debug("mywriter done.")
|
logger.debug("mywriter done.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def myserver(self, reader, writer):
|
async def myserver(self, reader, writer):
|
||||||
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
# Start TwoPartyServer using TwoWayPipe (only requires bootstrap)
|
||||||
self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl())
|
self.server = capnp.TwoPartyServer(bootstrap=ExampleImpl())
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ hostname = 'localhost'
|
|||||||
|
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def cleanup():
|
def cleanup():
|
||||||
yield
|
yield
|
||||||
@@ -18,7 +19,7 @@ def cleanup():
|
|||||||
p.kill()
|
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_attempt = 0
|
||||||
server_attempts = 2
|
server_attempts = 2
|
||||||
done = False
|
done = False
|
||||||
@@ -35,7 +36,7 @@ def run_subprocesses(address, server, client, wildcard_server=False, ipv4_force=
|
|||||||
c_address = '{}:{}'.format(addr, port)
|
c_address = '{}:{}'.format(addr, port)
|
||||||
s_address = c_address
|
s_address = c_address
|
||||||
if wildcard_server:
|
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))
|
print("Forcing ipv4 -> {} => {} {}".format(address, c_address, s_address))
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
@@ -133,7 +134,13 @@ def test_addressbook_example(cleanup):
|
|||||||
assert ret == 0
|
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):
|
def test_async_example(cleanup):
|
||||||
address = '{}:36434'.format(hostname)
|
address = '{}:36434'.format(hostname)
|
||||||
server = 'async_server.py'
|
server = 'async_server.py'
|
||||||
@@ -141,7 +148,13 @@ def test_async_example(cleanup):
|
|||||||
run_subprocesses(address, server, client)
|
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):
|
def test_ssl_async_example(cleanup):
|
||||||
address = '{}:36435'.format(hostname)
|
address = '{}:36435'.format(hostname)
|
||||||
server = 'async_ssl_server.py'
|
server = 'async_ssl_server.py'
|
||||||
@@ -149,7 +162,13 @@ def test_ssl_async_example(cleanup):
|
|||||||
run_subprocesses(address, server, client, ipv4_force=False)
|
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):
|
def test_ssl_reconnecting_async_example(cleanup):
|
||||||
address = '{}:36436'.format(hostname)
|
address = '{}:36436'.format(hostname)
|
||||||
server = 'async_ssl_server.py'
|
server = 'async_ssl_server.py'
|
||||||
|
|||||||
@@ -116,4 +116,4 @@ def test_remove_import_hook():
|
|||||||
def test_bundled_import_hook():
|
def test_bundled_import_hook():
|
||||||
# stream.capnp should be bundled, or provided by the system capnproto
|
# stream.capnp should be bundled, or provided by the system capnproto
|
||||||
capnp.add_import_hook()
|
capnp.add_import_hook()
|
||||||
import stream_capnp
|
import stream_capnp # noqa: F401
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ def test_simple_rpc_with_options():
|
|||||||
remote = cap.foo(i=5)
|
remote = cap.foo(i=5)
|
||||||
_ = remote.wait()
|
_ = remote.wait()
|
||||||
|
|
||||||
|
|
||||||
def test_simple_rpc_bootstrap():
|
def test_simple_rpc_bootstrap():
|
||||||
read, write = socket.socketpair()
|
read, write = socket.socketpair()
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import gc
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
|
||||||
import sys # add examples dir to sys.path
|
import sys # add examples dir to sys.path
|
||||||
import time
|
|
||||||
|
|
||||||
import capnp
|
import capnp
|
||||||
|
|
||||||
@@ -15,10 +13,11 @@ import calculator_client # noqa: E402
|
|||||||
import calculator_server # noqa: E402
|
import calculator_server # noqa: E402
|
||||||
|
|
||||||
# Uses run_subprocesses function
|
# Uses run_subprocesses function
|
||||||
import test_examples
|
import test_examples # noqa: E402
|
||||||
|
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def cleanup():
|
def cleanup():
|
||||||
yield
|
yield
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ def test_roundtrip_bytes_packed(all_types):
|
|||||||
msg = all_types.TestAllTypes.from_bytes_packed(message_bytes)
|
msg = all_types.TestAllTypes.from_bytes_packed(message_bytes)
|
||||||
test_regression.check_all_types(msg)
|
test_regression.check_all_types(msg)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def _warnings(expected_count=2, expected_text='This message has already been written once.'):
|
def _warnings(expected_count=2, expected_text='This message has already been written once.'):
|
||||||
with warnings.catch_warnings(record=True) as w:
|
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(issubclass(x.category, UserWarning) for x in w), w
|
||||||
assert all(expected_text in str(x.message) 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):
|
def test_roundtrip_file_multiple(all_types):
|
||||||
f = tempfile.TemporaryFile()
|
f = tempfile.TemporaryFile()
|
||||||
msg = all_types.TestAllTypes.new_message()
|
msg = all_types.TestAllTypes.new_message()
|
||||||
|
|||||||
Reference in New Issue
Block a user