[gerrit_util] Add type annotations

Bug: b/351071334
Change-Id: I9e31f14120953e89f6cef3759f595f6aca79cd33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754253
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
changes/53/5754253/4
Allen Li 1 year ago committed by LUCI CQ
parent 536cf08520
commit 29838db8fe

@ -911,8 +911,8 @@ class HttpConn(httplib2.Http):
return self.req_host
def CreateHttpConn(host,
path,
def CreateHttpConn(host: str,
path: str,
reqtype='GET',
headers: Optional[Dict[str, str]] = None,
body: Optional[Dict] = None,
@ -1054,7 +1054,7 @@ def ReadHttpResponse(conn: HttpConn,
def ReadHttpJsonResponse(
conn, accept_statuses: Container[int] = frozenset([200])) -> Dict:
conn, accept_statuses: Container[int] = frozenset([200])) -> dict:
"""Parses an https response as json."""
fh = ReadHttpResponse(conn, accept_statuses)
# The first line of the response should always be: )]}'
@ -1253,7 +1253,7 @@ def GetChangeDetail(host, change, o_params=None):
return ReadHttpJsonResponse(CreateHttpConn(host, path))
def GetChangeCommit(host, change, revision='current'):
def GetChangeCommit(host: str, change: str, revision: str = 'current') -> dict:
"""Query a Gerrit server for a revision associated with a change."""
path = 'changes/%s/revisions/%s/commit?links' % (change, revision)
return ReadHttpJsonResponse(CreateHttpConn(host, path))

Loading…
Cancel
Save