Skip to content

Commit

Permalink
Frank feedbacks
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Harkins <[email protected]>
  • Loading branch information
mickahell committed Sep 1, 2023
1 parent 810cd48 commit 9da7841
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions ecosystem/daos/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
└── members
   └── repo-name.toml
"""
from __future__ import annotations
from typing import Optional
import json
from pathlib import Path
Expand Down Expand Up @@ -117,7 +118,7 @@ def delete(self, repo_url: str):
with self.storage as data:
del data[repo_url]

def get_by_url(self, url: str) -> Optional[Repository]:
def get_by_url(self, url: str) -> Repository | None:
"""
Returns repository by URL.
"""
Expand Down Expand Up @@ -239,11 +240,14 @@ def add_repo_style_result(self, repo_url: str, style_result: StyleResult):
"""
repo = self.get_by_url(repo_url)

new_style_results = [
tr for tr in repo.styles_results if tr.style_type != style_result.style_type
] + [style_result]
repo.styles_results = new_style_results
self.write(repo)
if repo is not None:
new_style_results = [
tr
for tr in repo.styles_results
if tr.style_type != style_result.style_type
] + [style_result]
repo.styles_results = new_style_results
self.write(repo)

def add_repo_coverage_result(self, repo_url: str, coverage_result: CoverageResult):
"""
Expand All @@ -255,10 +259,11 @@ def add_repo_coverage_result(self, repo_url: str, coverage_result: CoverageResul
"""
repo = self.get_by_url(repo_url)

new_coverage_results = [
tr
for tr in repo.coverages_results
if tr.coverage_type != coverage_result.coverage_type
] + [coverage_result]
repo.coverages_results = new_coverage_results
self.write(repo)
if repo is not None:
new_coverage_results = [
tr
for tr in repo.coverages_results
if tr.coverage_type != coverage_result.coverage_type
] + [coverage_result]
repo.coverages_results = new_coverage_results
self.write(repo)

0 comments on commit 9da7841

Please sign in to comment.