commit:     ac309733f5680c10bf95bf5d7e318e6e4c1d0ee9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 31 16:44:15 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 31 16:44:15 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=ac309733

PythonPackageNameCheck: update docs & add tests

Follows: 4438566500fdf116ba36c3c407022e89541867d6
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/python.py                              | 14 +++++++++-----
 .../PythonMismatchedPackageName/expected.json              |  1 +
 .../PythonMismatchedPackageName0-0.ebuild                  |  9 +++++++++
 .../dev-python/PythonMismatchedPackageName0/metadata.xml   |  7 +++++++
 .../PythonMismatchedPackageName1-0.ebuild                  |  9 +++++++++
 .../dev-python/PythonMismatchedPackageName1/metadata.xml   |  7 +++++++
 .../PythonMismatchedPackageName3-0.ebuild                  |  9 +++++++++
 .../dev-python/PythonMismatchedPackageName3/metadata.xml   |  8 ++++++++
 .../dev-python/python-mismatched-package-name/metadata.xml |  7 +++++++
 .../python-mismatched-package-name-0.ebuild                |  9 +++++++++
 10 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 6965d2a9..41edac21 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -699,7 +699,13 @@ class PythonGHDistfileSuffixCheck(Check):
 
 
 class PythonMismatchedPackageName(results.PackageResult, results.Info):
-    """Package name does not follow PyPI-based naming policy"""
+    """Package name does not follow PyPI-based naming policy.
+
+    All packages in ``dev-python/*`` that are published on PyPI, must be named 
to
+    match their respective PyPI names [#]_.
+
+    .. [#] 
https://projects.gentoo.org/python/guide/package-maintenance.html#package-name-policy
+    """
 
     def __init__(self, recommended: str, **kwargs):
         super().__init__(**kwargs)
@@ -707,8 +713,7 @@ class PythonMismatchedPackageName(results.PackageResult, 
results.Info):
 
     @property
     def desc(self) -> str:
-        return ("package name does not match remote-id, recommended name: "
-                f"{self.recommended!r}")
+        return f"package name does not match remote-id, recommended name: 
{self.recommended!r}"
 
 
 class PythonPackageNameCheck(Check):
@@ -739,5 +744,4 @@ class PythonPackageNameCheck(Check):
 
         pypi_name = pypi_remotes[0].name
         if normalize(pkg.package) != normalize(pypi_name):
-            yield PythonMismatchedPackageName(pypi_name.replace(".", "-"),
-                                              pkg=pkg)
+            yield PythonMismatchedPackageName(pypi_name.replace(".", "-"), 
pkg=pkg)

diff --git 
a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
 
b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
new file mode 100644
index 00000000..3c85ada5
--- /dev/null
+++ 
b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
@@ -0,0 +1 @@
+{"__class__": "PythonMismatchedPackageName", "category": "dev-python", 
"package": "PythonMismatchedPackageName1", "recommended": 
"MismatchedPackageName1"}

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild
 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild
new file mode 100644
index 00000000..0c3de1e6
--- /dev/null
+++ 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild
@@ -0,0 +1,9 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Ebuild with matching name with PyPI"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck";
+LICENSE="BSD"
+SLOT="0"

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml
new file mode 100644
index 00000000..07ce2e64
--- /dev/null
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <upstream>
+               <remote-id type="pypi">PythonMismatchedPackageName0</remote-id>
+       </upstream>
+</pkgmetadata>

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild
 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild
new file mode 100644
index 00000000..450671b5
--- /dev/null
+++ 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild
@@ -0,0 +1,9 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Ebuild with not matching name with PyPI"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck";
+LICENSE="BSD"
+SLOT="0"

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml
new file mode 100644
index 00000000..14221de3
--- /dev/null
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <upstream>
+               <remote-id type="pypi">MismatchedPackageName1</remote-id>
+       </upstream>
+</pkgmetadata>

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild
 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild
new file mode 100644
index 00000000..6126af5d
--- /dev/null
+++ 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild
@@ -0,0 +1,9 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Ebuild with multiple not matching name with PyPI"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck";
+LICENSE="BSD"
+SLOT="0"

diff --git 
a/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml 
b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml
new file mode 100644
index 00000000..3601354e
--- /dev/null
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <upstream>
+               <remote-id type="pypi">MismatchedPackageName3</remote-id>
+               <remote-id type="pypi">PackageName3</remote-id>
+       </upstream>
+</pkgmetadata>

diff --git 
a/testdata/repos/python/dev-python/python-mismatched-package-name/metadata.xml 
b/testdata/repos/python/dev-python/python-mismatched-package-name/metadata.xml
new file mode 100644
index 00000000..10320a70
--- /dev/null
+++ 
b/testdata/repos/python/dev-python/python-mismatched-package-name/metadata.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <upstream>
+               <remote-id 
type="pypi">python.mismatched.package.name</remote-id>
+       </upstream>
+</pkgmetadata>

diff --git 
a/testdata/repos/python/dev-python/python-mismatched-package-name/python-mismatched-package-name-0.ebuild
 
b/testdata/repos/python/dev-python/python-mismatched-package-name/python-mismatched-package-name-0.ebuild
new file mode 100644
index 00000000..0c3de1e6
--- /dev/null
+++ 
b/testdata/repos/python/dev-python/python-mismatched-package-name/python-mismatched-package-name-0.ebuild
@@ -0,0 +1,9 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Ebuild with matching name with PyPI"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck";
+LICENSE="BSD"
+SLOT="0"

Reply via email to