commit:     a953ed6a4770af7ab58839b0e7218f820b883e9c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 13 12:10:57 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 15 17:49:28 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=a953ed6a

python: Generalize Python{GHDistfileSuffix → Fetchable}Check

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/python.py                      | 26 +++++++++++++---------
 .../PythonGHDistfileSuffix/expected.json           |  1 +
 .../PythonGHDistfileSuffix/fix.patch               | 12 +++++-----
 .../PythonGHDistfileSuffix/expected.json           |  1 -
 .../PythonGHDistfileSuffix/Manifest                |  0
 .../PythonGHDistfileSuffix-0.ebuild                |  0
 .../PythonGHDistfileSuffix-1.ebuild                |  0
 .../PythonGHDistfileSuffix-1_p20220601.ebuild      |  0
 .../PythonGHDistfileSuffix-2.ebuild                |  0
 .../PythonGHDistfileSuffix/metadata.xml            |  0
 .../PythonGHDistfileSuffixNoPyPI/Manifest          |  0
 .../PythonGHDistfileSuffixNoPyPI-1.ebuild          |  0
 .../PythonGHDistfileSuffixNoPyPI/metadata.xml      |  0
 13 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 7cff5f12..8cd00782 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -687,29 +687,22 @@ class PythonGHDistfileSuffix(results.VersionResult, 
results.Warning):
         )
 
 
-class PythonGHDistfileSuffixCheck(Check):
-    """Check ebuilds with PyPI remotes for missing ".gh.tar.gz" suffixes."""
+class PythonFetchableCheck(Check):
+    """Perform Python-specific checks on fetchables."""
 
     required_addons = (addons.UseAddon,)
-    known_results = frozenset([PythonGHDistfileSuffix])
+    known_results = frozenset({PythonGHDistfileSuffix})
 
     def __init__(self, *args, use_addon):
         super().__init__(*args)
         self.iuse_filter = use_addon.get_filter("fetchables")
 
-    def feed(self, pkg):
+    def check_gh_suffix(self, pkg, fetchables):
         # consider only packages with pypi remote-id
         if not any(u.type == "pypi" for u in pkg.upstreams):
             return
 
         # look for GitHub archives
-        fetchables, _ = self.iuse_filter(
-            (fetch.fetchable,),
-            pkg,
-            pkg.generate_fetchables(
-                allow_missing_checksums=True, ignore_unknown_mirrors=True, 
skip_default_mirrors=True
-            ),
-        )
         for f in fetchables:
             # skip files that have the correct suffix already
             if f.filename.endswith(".gh.tar.gz"):
@@ -725,6 +718,17 @@ class PythonGHDistfileSuffixCheck(Check):
                     yield PythonGHDistfileSuffix(f.filename, uri, pkg=pkg)
                     break
 
+    def feed(self, pkg):
+        fetchables, _ = self.iuse_filter(
+            (fetch.fetchable,),
+            pkg,
+            pkg.generate_fetchables(
+                allow_missing_checksums=True, ignore_unknown_mirrors=True, 
skip_default_mirrors=True
+            ),
+        )
+
+        yield from self.check_gh_suffix(pkg, fetchables)
+
 
 class PythonMismatchedPackageName(results.PackageResult, results.Info):
     """Package name does not follow PyPI-based naming policy.

diff --git 
a/testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/expected.json
 
b/testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/expected.json
new file mode 100644
index 00000000..c7f159ba
--- /dev/null
+++ 
b/testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/expected.json
@@ -0,0 +1 @@
+{"__class__": "PythonGHDistfileSuffix", "category": "PythonFetchableCheck", 
"package": "PythonGHDistfileSuffix", "version": "1", "filename": 
"PythonGHDistfileSuffix-1.tar.gz", "uri": 
"https://github.com/examplesoft/example/archive/v1.tar.gz"}

diff --git 
a/testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/fix.patch
 
b/testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/fix.patch
similarity index 52%
rename from 
testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/fix.patch
rename to 
testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/fix.patch
index 64fa2747..3c54db64 100644
--- 
a/testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/fix.patch
+++ 
b/testdata/data/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/fix.patch
@@ -1,12 +1,12 @@
-diff -dupr python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest 
fixed/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest
---- python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest 
2022-05-23 18:46:35.688579562 +0200
-+++ fixed/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest  
2022-05-23 18:57:56.720475178 +0200
+diff -dupr python/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest 
fixed/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest
+--- python/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest        
2022-05-23 18:46:35.688579562 +0200
++++ fixed/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest 2022-05-23 
18:57:56.720475178 +0200
 @@ -1 +1 @@
 -DIST PythonGHDistfileSuffix-1.tar.gz 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05
 +DIST PythonGHDistfileSuffix-1.gh.tar.gz 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05
-diff -dupr 
python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
 
fixed/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
---- 
python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
  2022-05-23 18:44:44.916287099 +0200
-+++ 
fixed/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
   2022-05-23 18:58:08.377420003 +0200
+diff -dupr 
python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
 
fixed/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
+--- 
python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
 2022-05-23 18:44:44.916287099 +0200
++++ 
fixed/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
  2022-05-23 18:58:08.377420003 +0200
 @@ -7,7 +7,7 @@ DESCRIPTION="Ebuild with tarball missing
  HOMEPAGE="https://github.com/pkgcore/pkgcheck";
  SRC_URI="

diff --git 
a/testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/expected.json
 
b/testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/expected.json
deleted file mode 100644
index 7a81666a..00000000
--- 
a/testdata/data/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/expected.json
+++ /dev/null
@@ -1 +0,0 @@
-{"__class__": "PythonGHDistfileSuffix", "category": 
"PythonGHDistfileSuffixCheck", "package": "PythonGHDistfileSuffix", "version": 
"1", "filename": "PythonGHDistfileSuffix-1.tar.gz", "uri": 
"https://github.com/examplesoft/example/archive/v1.tar.gz"}

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest
 b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/Manifest
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/Manifest

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-0.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-0.ebuild
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-0.ebuild
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-0.ebuild

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1.ebuild

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1_p20220601.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1_p20220601.ebuild
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1_p20220601.ebuild
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-1_p20220601.ebuild

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-2.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-2.ebuild
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-2.ebuild
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/PythonGHDistfileSuffix-2.ebuild

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/metadata.xml
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/metadata.xml
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffix/metadata.xml
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffix/metadata.xml

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/Manifest
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/Manifest
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/Manifest
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/Manifest

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/PythonGHDistfileSuffixNoPyPI-1.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/PythonGHDistfileSuffixNoPyPI-1.ebuild
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/PythonGHDistfileSuffixNoPyPI-1.ebuild
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/PythonGHDistfileSuffixNoPyPI-1.ebuild

diff --git 
a/testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/metadata.xml
 
b/testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/metadata.xml
similarity index 100%
rename from 
testdata/repos/python/PythonGHDistfileSuffixCheck/PythonGHDistfileSuffixNoPyPI/metadata.xml
rename to 
testdata/repos/python/PythonFetchableCheck/PythonGHDistfileSuffixNoPyPI/metadata.xml

Reply via email to