From 29c291b98144a4501d820a52d619bbd58980ba44 Mon Sep 17 00:00:00 2001 From: Tommy Ip Date: Thu, 29 Dec 2016 11:34:27 +0000 Subject: [PATCH] mypy: Annotate *api/integrations/perforce/zulip_change-commit.py*. --- .../perforce/zulip_change-commit.py | 22 ++++++++++--------- tools/run-mypy | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/api/integrations/perforce/zulip_change-commit.py b/api/integrations/perforce/zulip_change-commit.py index 146f0b57ac..f6dcc107d8 100755 --- a/api/integrations/perforce/zulip_change-commit.py +++ b/api/integrations/perforce/zulip_change-commit.py @@ -44,6 +44,7 @@ import git_p4 __version__ = "0.1" sys.path.insert(0, os.path.dirname(__file__)) +from typing import Any, Dict, Optional, Text import zulip_perforce_config as config if config.ZULIP_API_PATH is not None: @@ -54,11 +55,11 @@ client = zulip.Client( email=config.ZULIP_USER, site=config.ZULIP_SITE, api_key=config.ZULIP_API_KEY, - client="ZulipPerforce/" + __version__) + client="ZulipPerforce/" + __version__) # type: zulip.Client try: - changelist = int(sys.argv[1]) - changeroot = sys.argv[2] + changelist = int(sys.argv[1]) # type: int + changeroot = sys.argv[2] # type: str except IndexError: print("Wrong number of arguments.\n\n", end=' ', file=sys.stderr) print(__doc__, file=sys.stderr) @@ -68,22 +69,23 @@ except ValueError: print(__doc__, file=sys.stderr) sys.exit(-1) -metadata = git_p4.p4_describe(changelist) +metadata = git_p4.p4_describe(changelist) # type: Dict[str, str] -destination = config.commit_notice_destination(changeroot, changelist) +destination = config.commit_notice_destination(changeroot, changelist) # type: Optional[Dict[str, str]] if destination is None: # Don't forward the notice anywhere sys.exit(0) -message = """**{0}** committed revision @{1} to `{2}`. - -> {3} -""".format(metadata["user"], metadata["change"], changeroot, metadata["desc"]) +message = "**{0}** committed revision @{1} to `{2}`.\n\n> {3}".format( + metadata["user"], + metadata["change"], + changeroot, + metadata["desc"]) # type: str message_data = { "type": "stream", "to": destination["stream"], "subject": destination["subject"], "content": message, -} +} # type: Dict[str, Any] client.send_message(message_data) diff --git a/tools/run-mypy b/tools/run-mypy index bd4cc81226..9f984689ab 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -22,7 +22,6 @@ api/integrations/codebase/zulip_codebase_config.py api/integrations/git/zulip_git_config.py api/integrations/hg/zulip-changegroup.py api/integrations/perforce/git_p4.py -api/integrations/perforce/zulip_change-commit.py api/integrations/perforce/zulip_perforce_config.py api/integrations/svn/zulip_svn_config.py api/integrations/trac/zulip_trac_config.py