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

@ -3,36 +3,30 @@
import subprocess
import sys
def exit(message):
# type: (str) -> None
def exit(message: str) -> None:
print('PROBLEM!')
print(message)
sys.exit(1)
def run(command):
# type: (str) -> None
def run(command: str) -> None:
print('\n>>> ' + command)
subprocess.check_call(command.split())
def check_output(command):
# type: (str) -> str
def check_output(command: str) -> str:
return subprocess.check_output(command.split()).decode('ascii')
def get_git_branch():
# type: () -> str
def get_git_branch() -> str:
command = 'git rev-parse --abbrev-ref HEAD'
output = check_output(command)
return output.strip()
def check_git_pristine():
# type: () -> None
def check_git_pristine() -> None:
command = 'git status --porcelain'
output = check_output(command)
if output.strip():
exit('Git is not pristine:\n' + output)
def ensure_on_clean_master():
# type: () -> None
def ensure_on_clean_master() -> None:
branch = get_git_branch()
if branch != 'master':
exit('You are still on a feature branch: %s' % (branch,))
@ -40,8 +34,7 @@ def ensure_on_clean_master():
run('git fetch upstream master')
run('git rebase upstream/master')
def create_pull_branch(pull_id):
# type: (int) -> None
def create_pull_branch(pull_id: int) -> None:
run('git fetch upstream pull/%d/head' % (pull_id,))
run('git checkout -B review-%s FETCH_HEAD' % (pull_id,))
run('git rebase upstream/master')
@ -53,8 +46,7 @@ def create_pull_branch(pull_id):
print(subprocess.check_output(['git', 'log', 'HEAD~..',
'--pretty=format:Author: %an']))
def review_pr():
# type: () -> None
def review_pr() -> None:
try:
pull_id = int(sys.argv[1])
except Exception: