From af2af57df8f95d503250332f87452bb23ee0898c Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Sat, 28 Mar 2026 10:29:56 +0100 Subject: [PATCH] PythonPackageNameCheck: fix TypeError on empty PyPi remote Skip check when the PyPI remote-id in metadata.xml is empty and add a test package. Signed-off-by: Florian Albrechtskirchinger --- src/pkgcheck/checks/python.py | 7 ++++++- .../PythonMismatchedPackageName4-0.ebuild | 9 +++++++++ .../dev-python/PythonMismatchedPackageName4/metadata.xml | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 testdata/repos/python/dev-python/PythonMismatchedPackageName4/PythonMismatchedPackageName4-0.ebuild create mode 100644 testdata/repos/python/dev-python/PythonMismatchedPackageName4/metadata.xml diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py index 2ba590add..411e4fc45 100644 --- a/src/pkgcheck/checks/python.py +++ b/src/pkgcheck/checks/python.py @@ -1102,6 +1102,12 @@ def feed(self, pkgs): if len(pypi_remotes) != 1: return + pypi_name = pypi_remotes[0].name + + # skip empty remotes + if pypi_name is None: + return + def normalize(project: str) -> str: """ Normalize project name using PEP 503 rules @@ -1110,6 +1116,5 @@ def normalize(project: str) -> str: """ return PROJECT_SYMBOL_NORMALIZE_RE.sub("-", project).lower() - pypi_name = pypi_remotes[0].name if pkg.package != normalize(pypi_name): yield PythonMismatchedPackageName(normalize(pypi_name), pkg=pkg) diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName4/PythonMismatchedPackageName4-0.ebuild b/testdata/repos/python/dev-python/PythonMismatchedPackageName4/PythonMismatchedPackageName4-0.ebuild new file mode 100644 index 000000000..44ce51c21 --- /dev/null +++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName4/PythonMismatchedPackageName4-0.ebuild @@ -0,0 +1,9 @@ +# Copyright 2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DESCRIPTION="Ebuild with empty PyPi remote-id in metadata.xml" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0" diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName4/metadata.xml b/testdata/repos/python/dev-python/PythonMismatchedPackageName4/metadata.xml new file mode 100644 index 000000000..0de451e63 --- /dev/null +++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName4/metadata.xml @@ -0,0 +1,7 @@ + + + + + + +