[scm] Add type annotations

Otherwise pyright assumes a ton of values here are bytes

Bug: b/351071334
Change-Id: Ib360c27f6f82d35bcf885c5918b6def4ca26825f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5744594
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
changes/94/5744594/2
Allen Li 7 months ago committed by LUCI CQ
parent 9173d3dc80
commit 9ad0a20472

@ -3,6 +3,8 @@
# found in the LICENSE file.
"""SCM-specific utility classes."""
from __future__ import annotations
import abc
import os
import pathlib
@ -462,7 +464,7 @@ class GIT(object):
return env
@staticmethod
def Capture(args, cwd=None, strip_out=True, **kwargs):
def Capture(args, cwd=None, strip_out=True, **kwargs) -> str | bytes:
kwargs.setdefault('env', GIT.ApplyEnvVars(kwargs))
kwargs.setdefault('cwd', cwd)
kwargs.setdefault('autostrip', strip_out)
@ -813,10 +815,11 @@ class GIT(object):
return commit_hashes
@staticmethod
def GetCheckoutRoot(cwd):
def GetCheckoutRoot(cwd) -> str:
"""Returns the top level directory of a git checkout as an absolute path.
"""
root = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd)
root: str = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd)
assert isinstance(root, str)
return os.path.abspath(os.path.join(cwd, root))
@staticmethod

Loading…
Cancel
Save