From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9175E15800F for ; Fri, 20 Jan 2023 15:01:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8B25CE084A; Fri, 20 Jan 2023 15:01:53 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6E36EE084A for ; Fri, 20 Jan 2023 15:01:53 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4FD76340CB1 for ; Fri, 20 Jan 2023 15:01:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7FFEE84D for ; Fri, 20 Jan 2023 15:01:50 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1674226896.59e9fd40f4a696f262f302b71daec703c719c413.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/ X-VCS-Repository: proj/pkgcore/pkgcheck X-VCS-Files: src/pkgcheck/checks/git.py X-VCS-Directories: src/pkgcheck/checks/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 59e9fd40f4a696f262f302b71daec703c719c413 X-VCS-Branch: master Date: Fri, 20 Jan 2023 15:01:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fab126d6-e2dd-43e8-b47d-050604f9d33b X-Archives-Hash: 502c743b3689fb3f5c370593639ca779 commit: 59e9fd40f4a696f262f302b71daec703c719c413 Author: Arthur Zamarin gentoo org> AuthorDate: Fri Jan 20 15:01:36 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Fri Jan 20 15:01:36 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=59e9fd40 checks.git: add type annotations Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcheck/checks/git.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py index a54ce61e..6e48d47f 100644 --- a/src/pkgcheck/checks/git.py +++ b/src/pkgcheck/checks/git.py @@ -34,7 +34,7 @@ class GitCommitsRepoSource(sources.RepoSource): required_addons = (git.GitAddon,) - def __init__(self, options, git_addon): + def __init__(self, options, git_addon: git.GitAddon): source = git_addon.commits_repo(git.GitChangedRepo) super().__init__(options, source) @@ -49,7 +49,7 @@ class GitCommitsSource(sources.Source): scope = base.commit_scope required_addons = (git.GitAddon,) - def __init__(self, *args, git_addon): + def __init__(self, *args, git_addon: git.GitAddon): super().__init__(*args, source=git_addon.commits()) @@ -100,9 +100,7 @@ class _DroppedKeywords(results.PackageResult): def desc(self): s = pluralism(self.keywords) keywords = ", ".join(self.keywords) - return ( - f"commit {self.commit} (or later) dropped {self._status} " f"keyword{s}: [ {keywords} ]" - ) + return f"commit {self.commit} (or later) dropped {self._status} keyword{s}: [ {keywords} ]" class DroppedUnstableKeywords(_DroppedKeywords, results.Error): @@ -243,11 +241,11 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): # package categories that are committed with stable keywords allowed_direct_stable = frozenset(["acct-user", "acct-group"]) - def __init__(self, *args, git_addon): + def __init__(self, *args, git_addon: git.GitAddon): super().__init__(*args) self.today = datetime.today() self.repo = self.options.target_repo - self.valid_arches = self.options.target_repo.known_arches + self.valid_arches: frozenset[str] = self.options.target_repo.known_arches self._git_addon = git_addon self._cleanup = [] @@ -280,7 +278,7 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): old_keywords = set().union(*(p.keywords for p in removal_repo.match(pkg.unversioned_atom))) new_keywords = set().union(*(p.keywords for p in self.repo.match(pkg.unversioned_atom))) - dropped_keywords = old_keywords - new_keywords + dropped_keywords: set[str] = old_keywords - new_keywords dropped_stable_keywords = dropped_keywords & self.valid_arches dropped_unstable_keywords = set() for keyword in (x for x in dropped_keywords if x[0] == "~"): @@ -482,7 +480,7 @@ class BadCommitSummary(results.CommitResult, results.Style): return f"commit {self.commit}, {self.error}: {self.summary!r}" -def verify_tags(*tags, required=False): +def verify_tags(*tags: str, required: bool = False): """Decorator to register commit tag verification methods.""" class decorator: @@ -534,21 +532,20 @@ class GitCommitMessageCheck(GentooRepoCheck, GitCommitsCheck): ) @verify_tags("Signed-off-by", required=True) - def _signed_off_by_tag(self, tag, values, commit): + def _signed_off_by_tag(self, tag: str, values: list[str], commit: git.GitCommit): """Verify commit contains all required sign offs in accordance with GLEP 76.""" required_sign_offs = {commit.author, commit.committer} - missing_sign_offs = required_sign_offs.difference(values) - if missing_sign_offs: + if missing_sign_offs := required_sign_offs.difference(values): yield MissingSignOff(sorted(missing_sign_offs), commit=commit) @verify_tags("Gentoo-Bug") - def _deprecated_tag(self, tag, values, commit): + def _deprecated_tag(self, tag: str, values: list[str], commit: git.GitCommit): """Flag deprecated tags that shouldn't be used.""" for value in values: yield InvalidCommitTag(tag, value, f"{tag} tag is no longer valid", commit=commit) @verify_tags("Bug", "Closes") - def _bug_tag(self, tag, values, commit): + def _bug_tag(self, tag: str, values: list[str], commit: git.GitCommit): """Verify values are URLs for Bug/Closes tags.""" for value in values: parsed = urlparse(value) @@ -574,7 +571,7 @@ class GitCommitMessageCheck(GentooRepoCheck, GitCommitsCheck): ) @verify_tags("Fixes", "Reverts") - def _commit_tag(self, tag, values, commit): + def _commit_tag(self, tag, values, commit: git.GitCommit): """Verify referenced commits exist for Fixes/Reverts tags.""" self.git_cat_file.stdin.write("\n".join(values) + "\n") if self.git_cat_file.poll() is None: @@ -586,7 +583,7 @@ class GitCommitMessageCheck(GentooRepoCheck, GitCommitsCheck): if not status.startswith("commit "): yield InvalidCommitTag(tag, value, f"{status} commit", commit=commit) - def feed(self, commit): + def feed(self, commit: git.GitCommit): if len(commit.message) == 0: yield InvalidCommitMessage("no commit message", commit=commit) return