mypy: Annotate *api/integrations/svn/post-commit*.

This commit is contained in:
Tommy Ip 2016-12-28 14:06:16 +00:00 committed by Tim Abbott
parent adc678a3ab
commit cb98dd411e

View file

@ -34,6 +34,9 @@ import sys
import os.path import os.path
import pysvn import pysvn
if False:
from typing import Any, Dict, List, Optional, Text, Tuple, Union
sys.path.insert(0, os.path.dirname(__file__)) sys.path.insert(0, os.path.dirname(__file__))
import zulip_svn_config as config import zulip_svn_config as config
VERSION = "0.9" VERSION = "0.9"
@ -46,26 +49,27 @@ client = zulip.Client(
email=config.ZULIP_USER, email=config.ZULIP_USER,
site=config.ZULIP_SITE, site=config.ZULIP_SITE,
api_key=config.ZULIP_API_KEY, api_key=config.ZULIP_API_KEY,
client="ZulipSVN/" + VERSION) client="ZulipSVN/" + VERSION) # type: zulip.Client
svn = pysvn.Client() svn = pysvn.Client() # type: pysvn.Client
path, rev = sys.argv[1:] path, rev = sys.argv[1:] # type: Tuple[Text, Text]
# since its a local path, prepend "file://" # since its a local path, prepend "file://"
path = "file://" + path path = "file://" + path
entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[0] entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[0] # type: Dict[Text, Union[Text, pysvn.Revision, List[Dict[Text, pysvn.Revision]]]]
message = """**{0}** committed revision r{1} to `{2}`. message = "**{0}** committed revision r{1} to `{2}`.\n\n> {3}".format(
entry['author'],
rev,
path.split('/')[-1],
entry['revprops']['svn:log']) # type: Text
> {3} destination = config.commit_notice_destination(path, rev) # type: Optional[Dict[Text, Text]]
""".format(entry['author'], rev, path.split('/')[-1], entry['revprops']['svn:log'])
destination = config.commit_notice_destination(path, rev)
message_data = { message_data = {
"type": "stream", "type": "stream",
"to": destination["stream"], "to": destination["stream"],
"subject": destination["subject"], "subject": destination["subject"],
"content": message, "content": message,
} } # type: Dict[str, Any]
client.send_message(message_data) client.send_message(message_data)