Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Cyrill Burgener <[email protected]>
  • Loading branch information
Smeb and ctbur committed Aug 2, 2023
1 parent 60120e4 commit ddb0be7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions autopr/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -233,8 +233,8 @@ def reset_all():
name="from", help="reset using a file listing of repos written as <owner>/<name>"
)
@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)
Expand Down
12 changes: 6 additions & 6 deletions autopr/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Optional
from typing import List, Optional, Iterator

import marshmallow_dataclass

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit ddb0be7

Please sign in to comment.