cli: Cleaned up CPV_INFO type

BUG=b:187783171
TEST=./run_tests cli/deploy_unittest.py
TEST=Lease DUT, rebuild attr package w/ incompatible USE flag, attempt
to deploy to DUT.

Change-Id: I91456b932efe717b3b2f031a29828b0f0eae334e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4478498
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Tim Bain <tbain@google.com>
Tested-by: Tim Bain <tbain@google.com>
diff --git a/cli/deploy.py b/cli/deploy.py
index 50d04d4..e92b717 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -18,7 +18,7 @@
 import os
 from pathlib import Path
 import tempfile
-from typing import Dict, List, Set, Tuple
+from typing import Dict, List, NamedTuple, Set, Tuple
 
 from chromite.cli import command
 from chromite.lib import build_target_lib
@@ -59,6 +59,16 @@
 _DLC_INSTALL_ROOT = "/var/cache/dlc"
 
 
+class CpvInfo(NamedTuple):
+    """Holds a CPV and its associated information that we care about"""
+
+    cpv: Dict[str, package_info.CPV]
+    slot: str
+    rdep_raw: str
+    build_time: int
+    use: str
+
+
 class DeployError(Exception):
     """Thrown when an unrecoverable error is encountered during deploy."""
 
@@ -352,7 +362,7 @@
 
     def _BuildDB(
         self,
-        cpv_info: List[Tuple[Dict[str, package_info.CPV], str, str, int, str]],
+        cpv_info: List[CpvInfo],
         process_rdeps: bool,
         process_rev_rdeps: bool,
         installed_db: Dict[str, Dict[str, PkgInfo]] = None,
@@ -360,7 +370,7 @@
         """Returns a database of packages given a list of CPV info.
 
         Args:
-            cpv_info: A list of tuples containing package CPV and attributes.
+            cpv_info: A list of CpvInfos containing package CPV and attributes.
             process_rdeps: Whether to populate forward dependencies.
             process_rev_rdeps: Whether to populate reverse dependencies.
             installed_db: A database of installed packages for filtering
@@ -464,7 +474,9 @@
 
         try:
             self.target_db = self._BuildDB(
-                json.loads(result.stdout), process_rdeps, process_rev_rdeps
+                [CpvInfo(*cpv_info) for cpv_info in json.loads(result.stdout)],
+                process_rdeps,
+                process_rev_rdeps,
             )
         except ValueError as e:
             raise self.VartreeError(str(e))
@@ -482,7 +494,7 @@
             slot, rdep_raw, build_time, use = bintree.dbapi.aux_get(
                 cpv, ["SLOT", "RDEPEND", "BUILD_TIME", "USE"]
             )
-            binpkgs_info.append((cpv, slot, rdep_raw, build_time, use))
+            binpkgs_info.append(CpvInfo(cpv, slot, rdep_raw, build_time, use))
 
         try:
             self.binpkgs_db = self._BuildDB(