Fixing flake8 linting errors

- Enabling builds to fail on simple lint failures now
This commit is contained in:
Jacob Alexander
2020-11-20 23:38:13 -08:00
parent 2e6d7be1dd
commit a4ef16e831
14 changed files with 35 additions and 21 deletions

View File

@@ -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

View File

@@ -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
'''

View File

@@ -11,7 +11,7 @@
# for original project.
import fileinput
import fileinput # noqa
import os
import shutil
import tarfile

View File

@@ -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:

View File

@@ -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.

View File

@@ -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())

View File

@@ -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())

View File

@@ -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())

View File

@@ -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())

View File

@@ -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
@@ -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'

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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()