From 5c73d55d9146d4163a2db7de9e9e1eac04e6d4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Wed, 9 Oct 2024 22:29:14 +0200 Subject: [PATCH] Run ruff format --- nixprstatus/__main__.py | 6 +++++- nixprstatus/watchlist.py | 5 +++-- tests/test_watchlist.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nixprstatus/__main__.py b/nixprstatus/__main__.py index 1ff7154..8a1a347 100644 --- a/nixprstatus/__main__.py +++ b/nixprstatus/__main__.py @@ -65,12 +65,14 @@ def since( return typer.echo(count) + @watchlist_app.command() -def list(watchlist: str|None = None, format: OutputFormat = OutputFormat.CONSOLE): +def list(watchlist: str | None = None, format: OutputFormat = OutputFormat.CONSOLE): """List PRs in watchlist.""" wl = Watchlist.from_file() wl.print(format=format) + @watchlist_app.command() def add(pr: int): """Add PR to watchlist.""" @@ -80,6 +82,7 @@ def add(pr: int): info = wl.pr(pr) print(f"Added #{info.pr}: {info.title} to watchlist.") + @watchlist_app.command() def remove(pr: int): """Remove PR from watchlist.""" @@ -88,6 +91,7 @@ def remove(pr: int): wl.to_file() print(f"Removed #{pr} from watchlist.") + def main(): app() diff --git a/nixprstatus/watchlist.py b/nixprstatus/watchlist.py index 88b504f..31a175a 100644 --- a/nixprstatus/watchlist.py +++ b/nixprstatus/watchlist.py @@ -7,6 +7,7 @@ from rich.console import Console from nixprstatus.pr import get_pr + class OutputFormat(str, Enum): CONSOLE = "console" JSON = "json" @@ -50,7 +51,7 @@ class Watchlist(BaseModel): title = info["title"] self.prs.append(PRInfo(pr=pr, title=title)) - + def remove(self, pr: int): self.prs = [p for p in self.prs if p.pr != pr] @@ -64,7 +65,7 @@ class Watchlist(BaseModel): print(self.model_dump_json()) case _: raise ValueError(f"Unknown format: {format}") - + def pr(self, pr: int) -> PRInfo | None: for p in self.prs: if p.pr == pr: diff --git a/tests/test_watchlist.py b/tests/test_watchlist.py index d8c2168..b4db857 100644 --- a/tests/test_watchlist.py +++ b/tests/test_watchlist.py @@ -31,4 +31,4 @@ class TestWatchlist(unittest.TestCase): def test_get_pr(self): w = Watchlist(prs=[PRInfo(pr=1, title="PR 1")]) self.assertEqual(w.pr(1), PRInfo(pr=1, title="PR 1")) - self.assertEqual(w.pr(2), None) \ No newline at end of file + self.assertEqual(w.pr(2), None)