From ddb0be7408a0d056337099c9fb50c29e3a8f4104 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 2 Aug 2023 09:31:30 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Cyrill Burgener <41328971+ctbur@users.noreply.github.com> --- autopr/__init__.py | 6 +++--- autopr/database.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autopr/__init__.py b/autopr/__init__.py index ef7b504..953c890 100644 --- a/autopr/__init__.py +++ b/autopr/__init__.py @@ -1,7 +1,7 @@ import os import time from pathlib import Path -from typing import List, Optional +from typing import List, Optional, TextIO, Iterator import click from single_source import get_version @@ -233,8 +233,8 @@ def reset_all(): name="from", help="reset using a file listing of repos written as /" ) @click.argument("file", type=click.File("r")) -def reset_from(file): - repos = map(lambda l: l.strip(), file.readlines()) +def reset_from(file: TextIO): + repos: Iterator[str] = map(lambda l: l.strip(), file.readlines()) db = workdir.read_database(WORKDIR) db.reset_from(repos) workdir.write_database(WORKDIR, db) diff --git a/autopr/database.py b/autopr/database.py index a570700..0b05b6a 100644 --- a/autopr/database.py +++ b/autopr/database.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field -from typing import List, Optional +from typing import List, Optional, Iterator import marshmallow_dataclass @@ -66,13 +66,13 @@ def merge_into(self, from_db: "Database") -> None: if (repository.owner, repository.name) not in new_repos: repository.removed = True - def reset_from(self, selected_repos): + def reset_from(self, selected_repos: Iterator[str]): resets = {name: False for name in selected_repos} for repository in self.repositories: - id = f"{repository.owner}/{repository.name}" - if id in resets: - print(f"{id} was reset") - resets[id] = True + repo_id = f"{repository.owner}/{repository.name}" + if repo_id in resets: + print(f"{repo_id} was reset") + resets[repo_id] = True repository.done = False for repository, done in resets.items():