lib/build_target_lib.py: switch to typings module
Now that we're Python 3 only, we can use the typing module directly.
BUG=b:196895668
TEST=./run_tests chromite/lib/build_target_lib_unittest.py
Change-Id: If39df116f10bcb4ef5dd22bf2b636bdc86b56dbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3114111
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Alexander Nohe <nohe@chromium.org>
Commit-Queue: Alexander Nohe <nohe@chromium.org>
diff --git a/lib/build_target_lib.py b/lib/build_target_lib.py
index 0a37e6b..4220b54 100644
--- a/lib/build_target_lib.py
+++ b/lib/build_target_lib.py
@@ -6,6 +6,7 @@
import os
import re
+from typing import Optional
from chromite.api.gen.chromiumos import common_pb2
@@ -21,13 +22,16 @@
class BuildTarget(object):
"""Class to handle the build target information."""
- def __init__(self, name, profile=None, build_root=None):
+ def __init__(self,
+ name: str,
+ profile: Optional[str] = None,
+ build_root: Optional[str] = None):
"""Build Target init.
Args:
- name (str): The full name of the target.
- profile (str): The profile name.
- build_root (str): The path to the buildroot.
+ name: The full name of the target.
+ profile: The profile name.
+ build_root: The path to the buildroot.
"""
if not name:
raise InvalidNameError('Name is required.')
@@ -74,7 +78,7 @@
"""Turn a sysroot-relative path into an absolute path."""
return os.path.join(self.root, *[part.lstrip(os.sep) for part in args])
- def get_command(self, base_command):
+ def get_command(self, base_command: str) -> str:
"""Get the build target's variant of the given base command.
We create wrappers for many scripts that handle the build target's
@@ -84,10 +88,10 @@
TODO: Add optional validation the command exists.
Args:
- base_command (str): The wrapped command.
+ base_command: The wrapped command.
Returns:
- str: The build target's command wrapper.
+ The build target's command wrapper.
"""
return '%s-%s' % (base_command, self.name)