Skip to content

Commit

Permalink
mypy: Annotate *api/integrations/svn/post-commit*.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyip authored and timabbott committed Dec 28, 2016
1 parent 5316c36 commit 3d015eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 14 additions & 10 deletions api/integrations/svn/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import sys
import os.path
import pysvn

if False:
from typing import Any, Dict, List, Optional, Text, Tuple, Union

sys.path.insert(0, os.path.dirname(__file__))
import zulip_svn_config as config
VERSION = "0.9"
Expand All @@ -46,26 +49,27 @@ client = zulip.Client(
email=config.ZULIP_USER,
site=config.ZULIP_SITE,
api_key=config.ZULIP_API_KEY,
client="ZulipSVN/" + VERSION)
svn = pysvn.Client()
client="ZulipSVN/" + VERSION) # type: zulip.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://"
path = "file://" + path

entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[0]
message = """**{0}** committed revision r{1} to `{2}`.
> {3}
""".format(entry['author'], rev, path.split('/')[-1], entry['revprops']['svn:log'])
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}`.\n\n> {3}".format(
entry['author'],
rev,
path.split('/')[-1],
entry['revprops']['svn:log']) # type: Text

destination = config.commit_notice_destination(path, rev)
destination = config.commit_notice_destination(path, rev) # type: Optional[Dict[Text, Text]]

message_data = {
"type": "stream",
"to": destination["stream"],
"subject": destination["subject"],
"content": message,
}
} # type: Dict[str, Any]
client.send_message(message_data)
1 change: 0 additions & 1 deletion tools/run-mypy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ api/integrations/codebase/zulip_codebase_mirror
api/integrations/git/post-receive
api/integrations/nagios/nagios-notify-zulip
api/integrations/rss/rss-bot
api/integrations/svn/post-commit
api/integrations/twitter/twitter-bot
api/integrations/twitter/twitter-search-bot
tools/deprecated/iframe-bot/show-last-messages
Expand Down

0 comments on commit 3d015eb

Please sign in to comment.