typing: Convert function type annotations to Python 3 style.

Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and two fixes for use-before-define
issues:

-    def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None:
+    def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None:

-def init_from_options(options: Any, client: Optional[str] = None) -> Client:
+def init_from_options(options: Any, client: Optional[str] = None) -> 'Client':

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-04-18 15:59:12 -07:00 committed by Tim Abbott
parent 7c5f73dce9
commit 5428c5f296
42 changed files with 311 additions and 577 deletions

View file

@ -21,8 +21,7 @@ client = zulip.Client(
api_key=config.ZULIP_API_KEY,
client='ZulipOpenShift/' + VERSION)
def get_deployment_details():
# type: () -> Dict[str, str]
def get_deployment_details() -> Dict[str, str]:
# "gear deployments" output example:
# Activation time - Deployment ID - Git Ref - Git SHA1
# 2017-01-07 15:40:30 -0500 - 9e2b7143 - master - b9ce57c - ACTIVE
@ -34,8 +33,7 @@ def get_deployment_details():
branch=splits[2],
commit_id=splits[3])
def send_bot_message(deployment):
# type: (Dict[str, str]) -> None
def send_bot_message(deployment: Dict[str, str]) -> None:
destination = config.deployment_notice_destination(deployment['branch'])
if destination is None:
# No message should be sent

View file

@ -19,8 +19,7 @@ ZULIP_API_KEY = '0123456789abcdef0123456789abcdef'
# * stream "deployments"
# * topic "master"
# And similarly for branch "test-post-receive" (for use when testing).
def deployment_notice_destination(branch):
# type: (str) -> Optional[Dict[str, Text]]
def deployment_notice_destination(branch: str) -> Optional[Dict[str, Text]]:
if branch in ['master', 'test-post-receive']:
return dict(stream = 'deployments',
subject = '%s' % (branch,))
@ -40,8 +39,7 @@ def deployment_notice_destination(branch):
# * dep_id = deployment id
# * dep_time = deployment timestamp
def format_deployment_message(
app_name='', url='', branch='', commit_id='', dep_id='', dep_time=''):
# type: (str, str, str, str, str, str) -> str
app_name: str = '', url: str = '', branch: str = '', commit_id: str = '', dep_id: str = '', dep_time: str = '') -> str:
return 'Deployed commit `%s` (%s) in [%s](%s)' % (
commit_id, branch, app_name, url)