mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[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>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user