Skip to content

Commit

Permalink
Adjust code based on pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-codecov committed Sep 14, 2023
1 parent 7d09189 commit e71b2e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
8 changes: 2 additions & 6 deletions compare/commands/compare/compare.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from typing import Union

from shared.reports.resources import Report

from codecov.commands.base import BaseCommand
from services.comparison import Comparison, ComparisonReport, PullRequestComparison
from services.comparison import Comparison, ComparisonReport

from .interactors.fetch_impacted_files import FetchImpactedFiles

Expand All @@ -12,7 +8,7 @@ class CompareCommands(BaseCommand):
def fetch_impacted_files(
self,
comparison_report: ComparisonReport,
comparison: Union[PullRequestComparison, Comparison],
comparison: Comparison,
filters,
):
return self.get_interactor(FetchImpactedFiles).execute(
Expand Down
19 changes: 6 additions & 13 deletions compare/commands/compare/interactors/fetch_impacted_files.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import enum
from typing import List, Optional, Union

from shared.reports.resources import Report

from codecov.commands.base import BaseInteractor
from services.comparison import (
Comparison,
ComparisonReport,
ImpactedFile,
PullRequestComparison,
)
from services.comparison import Comparison, ComparisonReport, ImpactedFile
from services.report import files_belonging_to_flags


Expand All @@ -25,7 +18,7 @@ class FetchImpactedFiles(BaseInteractor):
def _apply_filters(
self,
impacted_files: Optional[List[ImpactedFile]],
comparison: Union[PullRequestComparison, Comparison],
comparison: Comparison,
filters,
):
parameter = filters.get("ordering", {}).get("parameter")
Expand All @@ -41,9 +34,9 @@ def _apply_filters(
files = files_belonging_to_flags(
commit_report=head_commit_report, flags=flags
)
impacted_files = list(
filter(lambda x: x.head_name in files, impacted_files)
)
impacted_files = [
file for file in impacted_files if file.head_name in files
]
return impacted_files

def get_attribute(
Expand Down Expand Up @@ -92,7 +85,7 @@ def sort_impacted_files(self, impacted_files, parameter, direction):
def execute(
self,
comparison_report: ComparisonReport,
comparison: Union[PullRequestComparison, Comparison],
comparison: Comparison,
filters,
):
if filters is None:
Expand Down
7 changes: 2 additions & 5 deletions graphql_api/types/comparison/comparison.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from asyncio import gather
from typing import List, Optional, Union
from typing import List, Optional

from ariadne import ObjectType, UnionType, convert_kwargs_to_snake_case

Expand All @@ -22,7 +22,6 @@
ComparisonReport,
ImpactedFile,
MissingComparisonReport,
PullRequestComparison,
)

comparison_bindable = ObjectType("Comparison")
Expand All @@ -40,9 +39,7 @@ def resolve_impacted_files(
comparison_report: ComparisonReport, info, filters=None
) -> List[ImpactedFile]:
command: CompareCommands = info.context["executor"].get_command("compare")
comparison: Union[PullRequestComparison, Comparison] = info.context.get(
"comparison", None
)
comparison: Comparison = info.context.get("comparison", None)

return command.fetch_impacted_files(comparison_report, comparison, filters)

Expand Down

0 comments on commit e71b2e4

Please sign in to comment.