1+ from dataclasses import dataclass
12from http import HTTPStatus
23from pathlib import Path
3- from typing import Any , Generic , List , Optional , Sequence , Tuple , TypeVar , Union
4+ from typing import Any , Dict , Generic , List , Optional , Sequence , Tuple , TypeVar , Union
45
56import click
67from tabulate import tabulate
78
8- from build . lib . launchable .testpath import unparse_test_path
9+ from launchable .testpath import unparse_test_path
910from launchable .utils .launchable_client import LaunchableClient
1011
11- try :
12- # for from 3.7
13- from dataclasses import dataclass
14- except ImportError :
15- # for 3.6
16- from dataclasses import dataclass
17-
1812
1913@dataclass (frozen = True )
2014class SubsetResultBase :
@@ -29,7 +23,7 @@ class SubsetResult(SubsetResultBase):
2923 duration_sec : float
3024
3125 @classmethod
32- def from_inspect_api (cls , result : dict [str , Any ], order : int ) -> "SubsetResult" :
26+ def from_inspect_api (cls , result : Dict [str , Any ], order : int ) -> "SubsetResult" :
3327 test_path = result .get ("testPath" , []) or []
3428 name = unparse_test_path (test_path )
3529 density = float (result .get ("density" ) or 0.0 )
@@ -93,8 +87,8 @@ def load(cls, client: LaunchableClient, subset_id: int) -> "SubsetResults":
9387
9488
9589@click .command ()
96- @click .argument ('file_before' , type = click .Path (exists = True ))
97- @click .argument ('file_after' , type = click .Path (exists = True ))
90+ @click .argument ('file_before' , type = click .Path (exists = True ), required = False )
91+ @click .argument ('file_after' , type = click .Path (exists = True ), required = False )
9892@click .option (
9993 '--subset-id-before' ,
10094 'subset_id_before' ,
@@ -107,6 +101,7 @@ def load(cls, client: LaunchableClient, subset_id: int) -> "SubsetResults":
107101 type = int ,
108102 help = 'Subset ID for the second subset to compare' ,
109103 metavar = "SUBSET_ID" )
104+ @click .pass_context
110105def subsets (context : click .core .Context , file_before , file_after , subset_id_before , subset_id_after ):
111106 """Compare subsets sourced from files or remote subset IDs."""
112107
@@ -125,7 +120,7 @@ def subsets(context: click.core.Context, file_before, file_after, subset_id_befo
125120
126121 if from_subset_id :
127122
128- client = LaunchableClient (app = context )
123+ client = LaunchableClient (app = context . obj )
129124 # for type check
130125 assert subset_id_before is not None and subset_id_after is not None
131126 _from_subset_ids (client = client , subset_id_before = subset_id_before , subset_id_after = subset_id_after )
@@ -152,7 +147,7 @@ def _from_subset_ids(client: LaunchableClient, subset_id_before: int, subset_id_
152147 for result in after_subset .results :
153148 total += 1
154149 if result .reason .startswith ("Changed file: " ):
155- affected .add (result .reason . removeprefix ("Changed file: " ))
150+ affected .add (result .reason [ len ("Changed file: " ):] )
156151
157152 test_name = result .name
158153 after_order = result .order
0 commit comments