ci: Add and configure mypy, and make it happy
This commit is contained in:
@@ -8,9 +8,10 @@ import struct
|
||||
import time
|
||||
|
||||
from colorlog import ColoredFormatter
|
||||
from nacl.signing import SigningKey
|
||||
from secret_handshake.network import SHSClient
|
||||
|
||||
from ssb.muxrpc import MuxRPCAPI, MuxRPCAPIException
|
||||
from ssb.muxrpc import MuxRPCAPI, MuxRPCAPIException, MuxRPCRequest
|
||||
from ssb.packet_stream import PacketStream, PSMessageType
|
||||
from ssb.util import load_ssb_secret
|
||||
|
||||
@@ -18,7 +19,7 @@ api = MuxRPCAPI()
|
||||
|
||||
|
||||
@api.define("createHistoryStream")
|
||||
def create_history_stream(connection, msg): # pylint: disable=unused-argument
|
||||
def create_history_stream(connection: PacketStream, msg: MuxRPCRequest) -> None: # pylint: disable=unused-argument
|
||||
"""Handle the createHistoryStream RPC call"""
|
||||
|
||||
print("create_history_stream", msg)
|
||||
@@ -27,13 +28,13 @@ def create_history_stream(connection, msg): # pylint: disable=unused-argument
|
||||
|
||||
|
||||
@api.define("blobs.createWants")
|
||||
def create_wants(connection, msg): # pylint: disable=unused-argument
|
||||
def create_wants(connection: PacketStream, msg: MuxRPCRequest) -> None: # pylint: disable=unused-argument
|
||||
"""Handle the createWants RPC call"""
|
||||
|
||||
print("create_wants", msg)
|
||||
|
||||
|
||||
async def test_client():
|
||||
async def test_client() -> None:
|
||||
"""The actual client implementation"""
|
||||
|
||||
async for msg in api.call(
|
||||
@@ -69,7 +70,7 @@ async def test_client():
|
||||
f.write(img_data)
|
||||
|
||||
|
||||
async def main(keypair):
|
||||
async def main(keypair: SigningKey) -> None:
|
||||
"""The main function to run"""
|
||||
|
||||
client = SHSClient("127.0.0.1", 8008, keypair, bytes(keypair.verify_key))
|
||||
|
@@ -5,6 +5,7 @@ import logging
|
||||
|
||||
from colorlog import ColoredFormatter
|
||||
from secret_handshake import SHSServer
|
||||
from secret_handshake.network import SHSDuplexStream
|
||||
|
||||
from ssb.muxrpc import MuxRPCAPI
|
||||
from ssb.packet_stream import PacketStream
|
||||
@@ -13,7 +14,7 @@ from ssb.util import load_ssb_secret
|
||||
api = MuxRPCAPI()
|
||||
|
||||
|
||||
async def on_connect(conn):
|
||||
async def on_connect(conn: SHSDuplexStream) -> None:
|
||||
"""Incoming connection handler"""
|
||||
|
||||
packet_stream = PacketStream(conn)
|
||||
@@ -25,7 +26,7 @@ async def on_connect(conn):
|
||||
print(msg)
|
||||
|
||||
|
||||
async def main():
|
||||
async def main() -> None:
|
||||
"""The main function to run"""
|
||||
server = SHSServer("127.0.0.1", 8008, load_ssb_secret()["keypair"])
|
||||
server.on_connect(on_connect)
|
||||
|
Reference in New Issue
Block a user