Replace black and flake8 with ruff for linting and formatting
- Remove .flake8; add [tool.ruff] and [tool.ruff.format] config in pyproject.toml (line-length 120, excludes, ignore list, per-file-ignores, mccabe complexity) - Update GitHub workflow lint job to run `ruff check .` and `ruff format --check .` - Swap black and flake8 for ruff in requirements.txt and Pipfile - Change capnp/__init__.py to ruff-style noqa comment - Move max-complexity into [tool.ruff.lint.mccabe], lint options into [tool.ruff.lint] - Add per-file-ignores for capnp/__init__.py (F401, F403, F405), remove inline noqa - Run ruff format across codebase (24 files) for consistent style
This commit is contained in:
@@ -23,9 +23,7 @@ class PowerFunction(calculator_capnp.Calculator.Function.Server):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="Connects to the Calculator server at the given address and does some RPCs"
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="Connects to the Calculator server at the given address and does some RPCs")
|
||||
parser.add_argument("host", help="HOST:PORT")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -111,9 +111,7 @@ async def new_connection(stream):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="""Runs the server bound to the given address/port ADDRESS. """
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="""Runs the server bound to the given address/port ADDRESS. """)
|
||||
|
||||
parser.add_argument("address", help="ADDRESS:PORT")
|
||||
|
||||
|
||||
@@ -45,21 +45,15 @@ async def main(host):
|
||||
addr, port = host.split(":")
|
||||
|
||||
# Setup SSL context
|
||||
ctx = ssl.create_default_context(
|
||||
ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert")
|
||||
)
|
||||
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert"))
|
||||
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET)
|
||||
except Exception:
|
||||
print("Try IPv6")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET6)
|
||||
|
||||
client = capnp.TwoPartyClient(stream)
|
||||
cap = client.bootstrap().cast_as(thread_capnp.Example)
|
||||
|
||||
@@ -28,9 +28,7 @@ async def new_connection(stream):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="""Runs the server bound to the given address/port ADDRESS. """
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="""Runs the server bound to the given address/port ADDRESS. """)
|
||||
|
||||
parser.add_argument("address", help="ADDRESS:PORT")
|
||||
|
||||
|
||||
@@ -42,9 +42,7 @@ async def new_connection(stream):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="""Runs the server bound to the given address/port ADDRESS. """
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="""Runs the server bound to the given address/port ADDRESS. """)
|
||||
|
||||
parser.add_argument("address", help="ADDRESS:PORT")
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ class PowerFunction(calculator_capnp.Calculator.Function.Server):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="Connects to the Calculator server at the given address and does some RPCs"
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="Connects to the Calculator server at the given address and does some RPCs")
|
||||
parser.add_argument("host", help="HOST:PORT")
|
||||
|
||||
return parser.parse_args()
|
||||
@@ -40,21 +38,15 @@ async def main(host):
|
||||
addr, port = host.split(":")
|
||||
|
||||
# Setup SSL context
|
||||
ctx = ssl.create_default_context(
|
||||
ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert")
|
||||
)
|
||||
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert"))
|
||||
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET)
|
||||
except Exception:
|
||||
print("Try IPv6")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET6)
|
||||
|
||||
client = capnp.TwoPartyClient(stream)
|
||||
|
||||
|
||||
@@ -112,9 +112,7 @@ class CalculatorImpl(calculator_capnp.Calculator.Server):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="""Runs the server bound to the given address/port ADDRESS. """
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="""Runs the server bound to the given address/port ADDRESS. """)
|
||||
|
||||
parser.add_argument("address", help="ADDRESS:PORT")
|
||||
|
||||
@@ -138,14 +136,10 @@ async def main():
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
server = await capnp.AsyncIoStream.create_server(
|
||||
new_connection, host, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
server = await capnp.AsyncIoStream.create_server(new_connection, host, port, ssl=ctx, family=socket.AF_INET)
|
||||
except Exception:
|
||||
print("Try IPv6")
|
||||
server = await capnp.AsyncIoStream.create_server(
|
||||
new_connection, host, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
server = await capnp.AsyncIoStream.create_server(new_connection, host, port, ssl=ctx, family=socket.AF_INET6)
|
||||
|
||||
async with server:
|
||||
await server.serve_forever()
|
||||
|
||||
@@ -33,21 +33,15 @@ async def main(host):
|
||||
addr, port = host.split(":")
|
||||
|
||||
# Setup SSL context
|
||||
ctx = ssl.create_default_context(
|
||||
ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert")
|
||||
)
|
||||
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert"))
|
||||
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET)
|
||||
except Exception:
|
||||
print("Try IPv6")
|
||||
stream = await capnp.AsyncIoStream.create_connection(
|
||||
addr, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
stream = await capnp.AsyncIoStream.create_connection(addr, port, ssl=ctx, family=socket.AF_INET6)
|
||||
|
||||
client = capnp.TwoPartyClient(stream)
|
||||
cap = client.bootstrap().cast_as(thread_capnp.Example)
|
||||
|
||||
@@ -36,9 +36,7 @@ async def new_connection(stream):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="""Runs the server bound to the given address/port ADDRESS. """
|
||||
)
|
||||
parser = argparse.ArgumentParser(usage="""Runs the server bound to the given address/port ADDRESS. """)
|
||||
parser.add_argument("address", help="ADDRESS:PORT")
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -56,14 +54,10 @@ async def main():
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
server = await capnp.AsyncIoStream.create_server(
|
||||
new_connection, host, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
server = await capnp.AsyncIoStream.create_server(new_connection, host, port, ssl=ctx, family=socket.AF_INET)
|
||||
except Exception:
|
||||
print("Try IPv6")
|
||||
server = await capnp.AsyncIoStream.create_server(
|
||||
new_connection, host, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
server = await capnp.AsyncIoStream.create_server(new_connection, host, port, ssl=ctx, family=socket.AF_INET6)
|
||||
|
||||
async with server:
|
||||
await server.serve_forever()
|
||||
|
||||
@@ -51,9 +51,7 @@ print(person.extraData)
|
||||
print(type(person.extraData))
|
||||
print()
|
||||
|
||||
person = addressbook_capnp.Person.new_message(
|
||||
allocate_seg_callable=MemoryViewAllocator()
|
||||
)
|
||||
person = addressbook_capnp.Person.new_message(allocate_seg_callable=MemoryViewAllocator())
|
||||
|
||||
person.init("extraData", 5)
|
||||
print(person.extraData)
|
||||
|
||||
Reference in New Issue
Block a user