diff --git a/patchoulene/src/patchoulene/__init__.py b/patchoulene/src/patchoulene/__init__.py index d3fa683..f3ec40d 100644 --- a/patchoulene/src/patchoulene/__init__.py +++ b/patchoulene/src/patchoulene/__init__.py @@ -1,15 +1,11 @@ -import difflib import json import os -import pathlib import re -import shlex -import subprocess import sys from . import b4 -from .message import * from .git import GitCommit, GitRepo +from .message import * def series_entry(c: GitCommit): @@ -269,7 +265,7 @@ def msg_possible_match( msgs = [f"... the replacement of patch {possible}?"] if not is_id_match: - msgs.append(f"* (weak match)") + msgs.append("* (weak match)") msgs.append(f' "{old_subject}"{is_identical}') return "\n".join(msgs) @@ -302,7 +298,7 @@ def msg_merged(commit: GitCommit, primary: str) -> str: if db.get(primary, {}).get("replacement", None) is not None: continue - possible_matches = set(pid for pid in upstream[1:] if pid in db) + possible_matches = {pid for pid in upstream[1:] if pid in db} possible_matches |= set(by_subject.get(clean, [])) possible_matches -= {primary} @@ -403,7 +399,7 @@ def msg_replacement_header(commit: GitCommit) -> str: msgs = [ f'Commit {commit.commit[:12]} ("{clean}"):', f" {dim(primary)}", - f" has replacement:", + " has replacement:", ] return "\n".join(msgs) @@ -448,12 +444,12 @@ def do_mail_check(db: dict[str, dict]) -> list[dict[str, list[dict[str, str]]]]: def msg_thread_replacement( this_thread: list[b4.PatchHeader], latest_thread: list[b4.PatchHeader] ) -> str: - msgs = [f"Patches:"] + msgs = ["Patches:"] for m in this_thread: msgs.append(f" {m.clean_subject()}") msgs.append(f" https://patch.msgid.link/{m.message_id()}") - msgs.append(f"... may have replacement:") + msgs.append("... may have replacement:") for m in latest_thread: msgs.append(f" {m.clean_subject()}") msgs.append(f" https://patch.msgid.link/{m.message_id()}") @@ -568,7 +564,7 @@ def do_mail_match(data: list[dict]): subj_b = replacement[idxb].subject() print(f" -> (B{idxb + 1}) {subj_b}", file=sys.stderr) else: - print(f" (no replacement)", file=sys.stderr) + print(" (no replacement)", file=sys.stderr) print(file=sys.stderr) print("Replacement version:", file=sys.stderr) @@ -669,7 +665,7 @@ def do_mail_match(data: list[dict]): match key: case "y": - print(f"(Accepted)", file=sys.stderr) + print("(Accepted)", file=sys.stderr) for i in range(len(current)): row = matrix[i] @@ -692,7 +688,7 @@ def do_mail_match(data: list[dict]): db[cur_pid]["replacement"] = rids break case "n": - print(f"(Ignored)", file=sys.stderr) + print("(Ignored)", file=sys.stderr) break case "c": for i in range(len(current)): @@ -764,7 +760,7 @@ def main(): "subject": clean, } - id_matches = set(pid for pid in guess[1:] if pid in db) + id_matches = {pid for pid in guess[1:] if pid in db} possible_matches = id_matches | set(by_subject.get(clean, [])) possible_matches -= {primary} @@ -785,7 +781,7 @@ def main(): print(f' "{clean}"', file=sys.stderr) print(f"... the replacement of patch {possible}?", file=sys.stderr) if possible not in id_matches: - print(f"* (weak match)", file=sys.stderr) + print("* (weak match)", file=sys.stderr) print(f' "{old_subject}"{is_identical}', file=sys.stderr) if prompt_yn(): db[possible]["replacement"] = primary @@ -803,5 +799,5 @@ def main(): write_patch_db(db) case _: - print(f"Bad usage", file=sys.stderr) + print("Bad usage", file=sys.stderr) sys.exit(1) diff --git a/patchoulene/src/patchoulene/git.py b/patchoulene/src/patchoulene/git.py index 497bf87..fa6e189 100644 --- a/patchoulene/src/patchoulene/git.py +++ b/patchoulene/src/patchoulene/git.py @@ -2,8 +2,6 @@ import shlex import subprocess -from .message import message_subject, clean_subject - RE_HASH_LIKE = re.compile(r"[0-9a-f]+") @@ -18,7 +16,7 @@ def __init__(self, commit: str, message: str): assert RE_HASH_LIKE.fullmatch(self.commit) def __repr__(self) -> str: - return f"GitCommit(commit={repr(self.commit)}, message={repr(self.message)})" + return f"GitCommit(commit={self.commit!r}, message={self.message!r})" class GitRepo: