Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit a73dee5

Browse files
committed
Use get_flag_names more consistently
We are using the `.flags` property in a lot of places where we only ever wanted the `.keys()`. So lets use `get_flag_names` instead, which does exactly that.
1 parent f77e387 commit a73dee5

24 files changed

+52
-37
lines changed

api/internal/tests/views/test_coverage_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
OwnerFactory,
1111
RepositoryFactory,
1212
)
13-
from shared.reports.resources import Report, ReportFile, ReportLine
13+
from shared.reports.resources import Report, ReportFile
14+
from shared.reports.types import ReportLine
1415
from shared.utils.sessions import Session
1516

1617
from services.components import Component

api/public/v2/report/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def filter_report(
112112
# empty report since the path is not part of the component
113113
return Report()
114114

115-
component_flags = component.get_matching_flags(report.flags.keys())
115+
component_flags = component.get_matching_flags(report.get_flag_names())
116116
if flag and len(component.flag_regexes) > 0 and flag not in component_flags:
117117
# empty report since the flag is not part of the component
118118
return Report()

api/public/v2/tests/test_api_compare_viewset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
RepositoryFactory,
1313
)
1414
from shared.reports.api_report_service import SerializableReport
15-
from shared.reports.resources import Report, ReportFile, ReportLine
16-
from shared.reports.types import ReportTotals
15+
from shared.reports.resources import Report, ReportFile
16+
from shared.reports.types import ReportLine, ReportTotals
1717
from shared.utils.merge import LineType
1818
from shared.utils.sessions import Session
1919

api/public/v2/tests/test_api_component_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
OwnerFactory,
88
RepositoryFactory,
99
)
10-
from shared.reports.resources import Report, ReportFile, ReportLine
10+
from shared.reports.resources import Report, ReportFile
11+
from shared.reports.types import ReportLine
1112
from shared.utils.sessions import Session
1213

1314
from services.components import Component

api/public/v2/tests/test_file_report_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
OwnerFactory,
1010
RepositoryFactory,
1111
)
12-
from shared.reports.resources import Report, ReportFile, ReportLine
12+
from shared.reports.resources import Report, ReportFile
13+
from shared.reports.types import ReportLine
1314
from shared.utils.sessions import Session
1415

1516
from core.models import Branch

api/public/v2/tests/test_flag_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
OwnerFactory,
88
RepositoryFactory,
99
)
10-
from shared.reports.resources import Report, ReportFile, ReportLine
10+
from shared.reports.resources import Report, ReportFile
11+
from shared.reports.types import ReportLine
1112
from shared.utils.sessions import Session
1213

1314
from reports.tests.factories import RepositoryFlagFactory

api/public/v2/tests/test_report_tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
OwnerFactory,
99
RepositoryFactory,
1010
)
11-
from shared.reports.resources import Report, ReportFile, ReportLine
11+
from shared.reports.resources import Report, ReportFile
12+
from shared.reports.types import ReportLine
1213
from shared.utils.sessions import Session
1314

1415
from utils.test_utils import APIClient

api/public/v2/tests/test_report_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
CommitFactory,
1414
RepositoryFactory,
1515
)
16-
from shared.reports.resources import Report, ReportFile, ReportLine
16+
from shared.reports.resources import Report, ReportFile
17+
from shared.reports.types import ReportLine
1718
from shared.utils.sessions import Session
1819

1920
from services.components import Component

api/public/v2/tests/test_totals_viewset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
OwnerFactory,
1111
RepositoryFactory,
1212
)
13-
from shared.reports.resources import Report, ReportFile, ReportLine
13+
from shared.reports.resources import Report, ReportFile
14+
from shared.reports.types import ReportLine
1415
from shared.utils.sessions import Session
1516

1617
from services.components import Component

compare/commands/compare/interactors/fetch_impacted_files.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _apply_filters(
4141
components_flags = []
4242

4343
head_commit_report = comparison.head_report_without_applied_diff
44+
report_flags = head_commit_report.get_flag_names()
4445
if components_filter:
4546
all_components = components.commit_components(
4647
comparison.head_commit, comparison.user
@@ -50,9 +51,7 @@ def _apply_filters(
5051
)
5152
for component in filtered_components:
5253
components_paths.extend(component.paths)
53-
components_flags.extend(
54-
component.get_matching_flags(head_commit_report.flags.keys())
55-
)
54+
components_flags.extend(component.get_matching_flags(report_flags))
5655

5756
# Flags & Components intersection
5857
if components_flags:
@@ -62,7 +61,7 @@ def _apply_filters(
6261
flags_filter = components_flags
6362

6463
if flags_filter:
65-
if set(flags_filter) & set(head_commit_report.flags):
64+
if set(flags_filter) & set(report_flags):
6665
files = files_belonging_to_flags(
6766
commit_report=head_commit_report, flags=flags_filter
6867
)

0 commit comments

Comments
 (0)