[git_cl] Fix some type checking errors

Bug: b/351071334
Change-Id: I15b8c7658c5959dbf88168e278525c2b8e2e4b2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754255
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
changes/55/5754255/4
Allen Li 9 months ago committed by LUCI CQ
parent 0cb94fcfa9
commit 40cece20d0

@ -2697,12 +2697,11 @@ class Changelist(object):
self._detail_cache.setdefault(cache_key, []).append((options_set, data)) self._detail_cache.setdefault(cache_key, []).append((options_set, data))
return data return data
def _GetChangeCommit(self, revision='current'): def _GetChangeCommit(self, revision: str = 'current') -> dict:
assert self.GetIssue(), 'issue must be set to query Gerrit' assert self.GetIssue(), 'issue must be set to query Gerrit'
try: try:
data = gerrit_util.GetChangeCommit(self.GetGerritHost(), data: dict = gerrit_util.GetChangeCommit(
self._GerritChangeIdentifier(), self.GetGerritHost(), self._GerritChangeIdentifier(), revision)
revision)
except gerrit_util.GerritError as e: except gerrit_util.GerritError as e:
if e.http_status == 404: if e.http_status == 404:
raise GerritChangeNotExists(self.GetIssue(), raise GerritChangeNotExists(self.GetIssue(),
@ -3310,7 +3309,7 @@ class Changelist(object):
upstream_branch_name, change_desc) upstream_branch_name, change_desc)
return parent return parent
def _UpdateWithExternalChanges(self): def _UpdateWithExternalChanges(self) -> Optional[str]:
"""Updates workspace with external changes. """Updates workspace with external changes.
Returns the commit hash that should be used as the merge base on upload. Returns the commit hash that should be used as the merge base on upload.
@ -3355,9 +3354,9 @@ class Changelist(object):
# Get latest Gerrit merge base. Use the first parent even if multiple # Get latest Gerrit merge base. Use the first parent even if multiple
# exist. # exist.
external_parent = self._GetChangeCommit( external_parent: dict = self._GetChangeCommit(
revision=external_ps)['parents'][0] revision=external_ps)['parents'][0]
external_base = external_parent['commit'] external_base: str = external_parent['commit']
branch = git_common.current_branch() branch = git_common.current_branch()
local_base = self.GetCommonAncestorWithUpstream() local_base = self.GetCommonAncestorWithUpstream()
@ -5264,9 +5263,9 @@ def UploadAllSquashed(options: optparse.Values,
cl = ordered_cls[0] cl = ordered_cls[0]
# We can only support external changes when we're only uploading one # We can only support external changes when we're only uploading one
# branch. # branch.
parent = cl._UpdateWithExternalChanges() if len( parent: Optional[str] = cl._UpdateWithExternalChanges() if len(
ordered_cls) == 1 else None ordered_cls) == 1 else None
orig_parent = None orig_parent: Optional[str] = None
if parent is None: if parent is None:
origin = '.' origin = '.'
branch = cl.GetBranch() branch = cl.GetBranch()

Loading…
Cancel
Save