Skip to content

Commit cda6e99

Browse files
committed
[chore] fix CI errors
1 parent 0824a30 commit cda6e99

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mypy = "<1.16.0"
2222
pre-commit = "*"
2323
responses = "*"
2424
types-click = "*"
25+
types-dataclasses = {markers = "python_version < '3.7'"}
2526
types-pkg_resources = "0.1.3"
2627
types-python-dateutil = "*"
2728
types-requests = "*"

launchable/commands/compare/subsets.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1+
from dataclasses import dataclass
12
from http import HTTPStatus
23
from 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

56
import click
67
from tabulate import tabulate
78

8-
from build.lib.launchable.testpath import unparse_test_path
9+
from launchable.testpath import unparse_test_path
910
from 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)
2014
class 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
110105
def 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

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ packages = find:
1717
install_requires =
1818
click>=8.0,<8.1;python_version=='3.6'
1919
click>=8.1,<8.2;python_version>'3.6'
20-
dataclass
20+
dataclasses;python_version=='3.6'
2121
requests>=2.25;python_version>='3.6'
2222
urllib3>=1.26
2323
junitparser>=4.0.0

tests/commands/compare/test_subsets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import responses
55

6-
from smart_tests.utils.http_client import get_base_url
6+
from launchable.utils.http_client import get_base_url
77
from tests.cli_test_case import CliTestCase
88

99

@@ -157,7 +157,7 @@ def tearDown(self):
157157
if os.path.exists("subset-after.txt"):
158158
os.remove("subset-after.txt")
159159

160-
@mock.patch.dict(os.environ, {"SMART_TESTS_TOKEN": CliTestCase.smart_tests_token})
160+
@mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
161161
@responses.activate
162162
def test_subsets_subset_ids(self):
163163
responses.add(

0 commit comments

Comments
 (0)