mypy: Annotate api/integrations/hg/zulip-changegroup.py

This commit is contained in:
Jackson 2016-12-30 02:56:26 +11:00 committed by showell
parent 1010927188
commit 3504396179

View file

@ -29,10 +29,13 @@ from __future__ import absolute_import
import zulip import zulip
from six.moves import range from six.moves import range
from typing import Any, Optional, Text
from mercurial import ui, repo
VERSION = "0.9" VERSION = "0.9"
def format_summary_line(web_url, user, base, tip, branch, node): def format_summary_line(web_url, user, base, tip, branch, node):
# type: (str, str, int, int, str, Text) -> Text
""" """
Format the first line of the message, which contains summary Format the first line of the message, which contains summary
information about the changeset and links to the changelog if a information about the changeset and links to the changelog if a
@ -58,6 +61,7 @@ def format_summary_line(web_url, user, base, tip, branch, node):
node=node[:12]) node=node[:12])
def format_commit_lines(web_url, repo, base, tip): def format_commit_lines(web_url, repo, base, tip):
# type: (str, repo, int, int) -> str
""" """
Format the per-commit information for the message, including the one-line Format the per-commit information for the message, including the one-line
commit summary and a link to the diff if a web URL has been configured: commit summary and a link to the diff if a web URL has been configured:
@ -83,6 +87,7 @@ def format_commit_lines(web_url, repo, base, tip):
return "\n".join(summary for summary in commit_summaries) return "\n".join(summary for summary in commit_summaries)
def send_zulip(email, api_key, site, stream, subject, content): def send_zulip(email, api_key, site, stream, subject, content):
# type: (str, str, str, str, str, Text) -> str
""" """
Send a message to Zulip using the provided credentials, which should be for Send a message to Zulip using the provided credentials, which should be for
a bot in most cases. a bot in most cases.
@ -101,6 +106,7 @@ def send_zulip(email, api_key, site, stream, subject, content):
client.send_message(message_data) client.send_message(message_data)
def get_config(ui, item): def get_config(ui, item):
# type: (ui, str) -> Optional[str]
try: try:
# configlist returns everything in lists. # configlist returns everything in lists.
return ui.configlist('zulip', item)[0] return ui.configlist('zulip', item)[0]
@ -108,6 +114,7 @@ def get_config(ui, item):
return None return None
def hook(ui, repo, **kwargs): def hook(ui, repo, **kwargs):
# type: (ui, repo, Optional[Text]) -> None
""" """
Invoked by configuring a [hook] entry in .hg/hgrc. Invoked by configuring a [hook] entry in .hg/hgrc.
""" """