mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[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>
This commit is contained in:
17
git_cl.py
17
git_cl.py
@@ -2697,12 +2697,11 @@ class Changelist(object):
|
||||
self._detail_cache.setdefault(cache_key, []).append((options_set, 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'
|
||||
try:
|
||||
data = gerrit_util.GetChangeCommit(self.GetGerritHost(),
|
||||
self._GerritChangeIdentifier(),
|
||||
revision)
|
||||
data: dict = gerrit_util.GetChangeCommit(
|
||||
self.GetGerritHost(), self._GerritChangeIdentifier(), revision)
|
||||
except gerrit_util.GerritError as e:
|
||||
if e.http_status == 404:
|
||||
raise GerritChangeNotExists(self.GetIssue(),
|
||||
@@ -3310,7 +3309,7 @@ class Changelist(object):
|
||||
upstream_branch_name, change_desc)
|
||||
return parent
|
||||
|
||||
def _UpdateWithExternalChanges(self):
|
||||
def _UpdateWithExternalChanges(self) -> Optional[str]:
|
||||
"""Updates workspace with external changes.
|
||||
|
||||
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
|
||||
# exist.
|
||||
external_parent = self._GetChangeCommit(
|
||||
external_parent: dict = self._GetChangeCommit(
|
||||
revision=external_ps)['parents'][0]
|
||||
external_base = external_parent['commit']
|
||||
external_base: str = external_parent['commit']
|
||||
|
||||
branch = git_common.current_branch()
|
||||
local_base = self.GetCommonAncestorWithUpstream()
|
||||
@@ -5264,9 +5263,9 @@ def UploadAllSquashed(options: optparse.Values,
|
||||
cl = ordered_cls[0]
|
||||
# We can only support external changes when we're only uploading one
|
||||
# branch.
|
||||
parent = cl._UpdateWithExternalChanges() if len(
|
||||
parent: Optional[str] = cl._UpdateWithExternalChanges() if len(
|
||||
ordered_cls) == 1 else None
|
||||
orig_parent = None
|
||||
orig_parent: Optional[str] = None
|
||||
if parent is None:
|
||||
origin = '.'
|
||||
branch = cl.GetBranch()
|
||||
|
||||
Reference in New Issue
Block a user