mypy: Annotate *api/integrations/svn/post-commit*.
This commit is contained in:
parent
adc678a3ab
commit
cb98dd411e
|
@ -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"
|
||||
|
@ -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}`.
|
||||
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
|
||||
|
||||
> {3}
|
||||
""".format(entry['author'], rev, path.split('/')[-1], entry['revprops']['svn:log'])
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue