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

Commit 46acbec

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 46acbec

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

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()

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
)

graphql_api/types/commit/commit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def get_sorted_path_contents(
160160
component_paths = []
161161
component_flags = []
162162

163+
report_flags = report.get_flag_names()
164+
163165
if component_filter:
164166
all_components = components_service.commit_components(commit, current_owner)
165167
filtered_components = components_service.filter_components_by_name_or_id(
@@ -173,18 +175,16 @@ def get_sorted_path_contents(
173175

174176
for component in filtered_components:
175177
component_paths.extend(component.paths)
176-
if report.flags:
177-
component_flags.extend(
178-
component.get_matching_flags(report.flags.keys())
179-
)
178+
if report_flags:
179+
component_flags.extend(component.get_matching_flags(report_flags))
180180

181181
if component_flags:
182182
if flags_filter:
183183
flags_filter = list(set(flags_filter) & set(component_flags))
184184
else:
185185
flags_filter = component_flags
186186

187-
if flags_filter and not report.flags:
187+
if flags_filter and not report_flags:
188188
return UnknownFlags(f"No coverage with chosen flags: {flags_filter}")
189189

190190
report_paths = ReportPaths(
@@ -325,8 +325,8 @@ def resolve_coverage_totals(
325325
@sentry_sdk.trace
326326
@commit_coverage_analytics_bindable.field("flagNames")
327327
@sync_to_async
328-
def resolve_coverage_flags(commit: Commit, info: GraphQLResolveInfo) -> List[str]:
329-
return commit.full_report.flags.keys()
328+
def resolve_coverage_flags(commit: Commit, info: GraphQLResolveInfo) -> list[str]:
329+
return commit.full_report.get_flag_names()
330330

331331

332332
@sentry_sdk.trace

graphql_api/types/comparison/comparison.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def resolve_impacted_files(
4545

4646
if filters and comparison:
4747
flags = filters.get("flags", [])
48-
if flags and set(flags).isdisjoint(set(comparison.head_report.flags)):
48+
if flags and set(flags).isdisjoint(
49+
set(comparison.head_report.get_flag_names())
50+
):
4951
return UnknownFlags()
5052

5153
return {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ dev-dependencies = [
7878
]
7979

8080
[tool.uv.sources]
81-
shared = { git = "https://github.com/codecov/shared", rev = "4755e7f77efc711c6ca34c2fb284edce71836402" }
81+
shared = { git = "https://github.com/codecov/shared", rev = "079d368c402758bc7ccb47572425237a9ebd9f9b" }

services/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def component_filtered_report(
3333
"""
3434
flags, paths = [], []
3535
for component in components:
36-
flags.extend(component.get_matching_flags(report.flags.keys()))
36+
flags.extend(component.get_matching_flags(report.get_flag_names()))
3737
paths.extend(component.paths)
3838
filtered_report = report.filter(flags=flags, paths=paths)
3939
return filtered_report

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)