From 43bf07bf15c12c570b7b87ee6b14a6850aca26da Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 15 Oct 2016 22:32:04 -0700 Subject: [PATCH] Annotate API scripts. --- bin/zulip-send | 11 +++++++---- examples/print-events | 3 +++ examples/print-messages | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/zulip-send b/bin/zulip-send index 3cd31ad..f296087 100755 --- a/bin/zulip-send +++ b/bin/zulip-send @@ -27,12 +27,18 @@ import os import optparse import logging +from typing import Any, Dict, List, Optional + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +import zulip logging.basicConfig() log = logging.getLogger('zulip-send') def do_send_message(client, message_data ): + # type: (zulip.Client, Dict[str, Any]) -> bool '''Sends a message and optionally prints status about the same.''' if message_data['type'] == 'stream': @@ -49,6 +55,7 @@ def do_send_message(client, message_data ): return False def main(argv=None): + # type: (Optional[List[str]]) -> int if argv is None: argv = sys.argv @@ -63,10 +70,6 @@ def main(argv=None): '--user' and '--api-key' arguments. """ - sys.path.append(os.path.join(os.path.dirname(__file__), '..')) - - import zulip - parser = optparse.OptionParser(usage=usage) # Grab parser options from the API common set diff --git a/examples/print-events b/examples/print-events index 78cb488..b74c13a 100755 --- a/examples/print-events +++ b/examples/print-events @@ -26,6 +26,8 @@ import sys import os import optparse +from typing import Any, Dict + usage = """print-events --user= --api-key= [options] Prints out certain events received by the indicated bot or user matching the filter below. @@ -44,6 +46,7 @@ parser.add_option_group(zulip.generate_option_group(parser)) client = zulip.init_from_options(options) def print_event(event): + # type: (Dict[str, Any]) -> None print(event) # This is a blocking call, and will continuously poll for new events diff --git a/examples/print-messages b/examples/print-messages index 134b030..515b6d9 100755 --- a/examples/print-messages +++ b/examples/print-messages @@ -26,6 +26,8 @@ import sys import os import optparse +from typing import Any, Dict + usage = """print-messages --user= --api-key= [options] Prints out each message received by the indicated bot or user. @@ -44,6 +46,7 @@ parser.add_option_group(zulip.generate_option_group(parser)) client = zulip.init_from_options(options) def print_message(message): + # type: (Dict[str, Any]) -> None print(message) # This is a blocking call, and will continuously poll for new messages