* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2022-10-13 17:06 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2022-10-13 17:06 UTC (permalink / raw
To: gentoo-commits
commit: b9dc3859c9a507639548ce292656388a4b6418e6
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 13 13:28:47 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 13 17:05:35 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=b9dc3859
PythonCheck: warn about use of distutils-r1 non-PEP517 mode
Closes: https://github.com/pkgcore/pkgcheck/issues/467
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/python.py | 33 ++++++++++++++++++++--
.../DistutilsNonPEP517Build/expected.json | 1 +
.../PythonCheck/DistutilsNonPEP517Build/fix.patch | 10 +++++++
.../DistutilsNonPEP517Build-0.ebuild | 10 +++++++
4 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 9bfa0bad..a1d5ff5f 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -139,6 +139,17 @@ class PythonEclassError(results.VersionResult, results.Error):
return self.msg
+class DistutilsNonPEP517Build(results.VersionResult, results.Warning):
+ """Ebuild uses the deprecated non-PEP517 build"""
+
+ @property
+ def desc(self):
+ return (
+ "uses deprecated non-PEP517 build mode, please switch to "
+ "DISTUTILS_USE_PEP517=..."
+ )
+
+
class PythonCheck(Check):
"""Python eclass checks.
@@ -150,6 +161,7 @@ class PythonCheck(Check):
known_results = frozenset([
MissingPythonEclass, PythonMissingRequiredUse,
PythonMissingDeps, PythonRuntimeDepInAnyR1, PythonEclassError,
+ DistutilsNonPEP517Build,
])
def scan_tree_recursively(self, deptree, expected_cls):
@@ -240,6 +252,20 @@ class PythonCheck(Check):
return True
+ def check_pep517_mode(self, item):
+ """Check whether PEP517 mode is used."""
+ # We're not interested in testing fake objects from TestPythonCheck
+ if not isinstance(item, sources._ParsedPkg) or not hasattr(item, 'tree'): # pragma: no cover
+ return True
+
+ for var_node, _ in bash.var_assign_query.captures(item.tree.root_node):
+ var_name = item.node_str(var_node.child_by_field_name('name'))
+
+ if var_name == "DISTUTILS_USE_PEP517":
+ return True
+
+ return False
+
def feed(self, pkg):
try:
eclass = get_python_eclass(pkg)
@@ -285,8 +311,11 @@ class PythonCheck(Check):
yield PythonMissingRequiredUse(pkg=pkg)
if not self.check_depend(pkg.rdepend, *(req_use_args[:2])):
yield PythonMissingDeps('RDEPEND', pkg=pkg)
- if 'distutils-r1' in pkg.inherited and not self.check_pep517_depend(pkg):
- yield PythonMissingDeps("BDEPEND", pkg=pkg, dep_value="DISTUTILS_DEPS")
+ if "distutils-r1" in pkg.inherited:
+ if not self.check_pep517_mode(pkg):
+ yield DistutilsNonPEP517Build(pkg=pkg)
+ if not self.check_pep517_depend(pkg):
+ yield PythonMissingDeps("BDEPEND", pkg=pkg, dep_value="DISTUTILS_DEPS")
else: # python-any-r1
for attr in ("rdepend", "pdepend"):
for p in iflatten_instance(getattr(pkg, attr), atom):
diff --git a/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/expected.json b/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/expected.json
new file mode 100644
index 00000000..db292bed
--- /dev/null
+++ b/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/expected.json
@@ -0,0 +1 @@
+{"__class__": "DistutilsNonPEP517Build", "category": "PythonCheck", "package": "DistutilsNonPEP517Build", "version": "0"}
diff --git a/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/fix.patch b/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/fix.patch
new file mode 100644
index 00000000..6ad28c31
--- /dev/null
+++ b/testdata/data/repos/python/PythonCheck/DistutilsNonPEP517Build/fix.patch
@@ -0,0 +1,10 @@
+diff -Naur python/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild fixed/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild
+--- python/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild 2022-10-13 15:21:07.676924455 +0200
++++ fixed/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild 2022-10-13 15:24:54.005682963 +0200
+@@ -1,5 +1,6 @@
+ EAPI=7
+
++DISTUTILS_USE_PEP517=setuptools
+ PYTHON_COMPAT=( python3_10 )
+
+ inherit distutils-r1
diff --git a/testdata/repos/python/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild b/testdata/repos/python/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild
new file mode 100644
index 00000000..03ff2937
--- /dev/null
+++ b/testdata/repos/python/PythonCheck/DistutilsNonPEP517Build/DistutilsNonPEP517Build-0.ebuild
@@ -0,0 +1,10 @@
+EAPI=7
+
+PYTHON_COMPAT=( python3_10 )
+
+inherit distutils-r1
+
+DESCRIPTION="Ebuild using non-PEP517 build"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+LICENSE="BSD"
+SLOT="0"
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2022-10-30 18:04 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2022-10-30 18:04 UTC (permalink / raw
To: gentoo-commits
commit: 5e05fd7c59d0853e6472bf65d619cedafb4880b7
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 30 18:02:16 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 30 18:02:16 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=5e05fd7c
MissingRemoteIdCheck: fix bad suggestion for downloads.sourceforge.net
For sourceforge, the order of regexes was bad, resulting in it catching
`downloads.sourceforge.net` as project under `sourceforge.net` instead,
which is very wrong. Fix the order, and update the test to check for
this case specially.
On the same note, add support for `sourceforge.io` as a site - cause
looks like it also appears in the wild.
Resolves: https://github.com/pkgcore/pkgcheck/issues/488
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/metadata_xml.py | 6 +++---
.../MissingRemoteIdCheck/MissingRemoteId/expected.json | 2 +-
.../MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-2.ebuild | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/pkgcheck/checks/metadata_xml.py b/src/pkgcheck/checks/metadata_xml.py
index 56dd2c94..06d62cf3 100644
--- a/src/pkgcheck/checks/metadata_xml.py
+++ b/src/pkgcheck/checks/metadata_xml.py
@@ -601,9 +601,9 @@ class MissingRemoteIdCheck(Check):
('pypi', r'https://files.pythonhosted.org/packages/source/\S/(?P<value>[^/]+)'),
('savannah', r'https://savannah.gnu.org/projects/(?P<value>[^/]+)'),
('savannah-nongnu', r'https://savannah.nongnu.org/projects/(?P<value>[^/]+)'),
- ('sourceforge', r'https://(?P<value>[^/]+).sourceforge.net/'),
- ('sourceforge', r'https://sourceforge.net/projects/(?P<value>[^/]+)'),
- ('sourceforge', r'https://downloads.sourceforge.net/(?:project/)?(?P<value>[^/]+)'),
+ ('sourceforge', r'https://downloads.sourceforge.(net|io)/(?:project/)?(?P<value>[^/]+)'),
+ ('sourceforge', r'https://sourceforge.(net|io)/projects/(?P<value>[^/]+)'),
+ ('sourceforge', r'https://(?P<value>[^/]+).sourceforge.(net|io)/'),
('sourcehut', r'https://sr.ht/(?P<value>[^/]+/[^/]+)'),
)
diff --git a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json
index ab5ae2d4..9d74b4e9 100644
--- a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json
+++ b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json
@@ -1,4 +1,4 @@
{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "gitlab", "value": "pkgcore/pkgcheck/extra/MissingRemoteId", "uri": "https://gitlab.com/pkgcore/pkgcheck/extra/MissingRemoteId/-/archive/1/MissingRemoteId-1.tar.bz2"}
{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "heptapod", "value": "pkgcore/pkgcore", "uri": "https://foss.heptapod.net/pkgcore/pkgcore/-/archive/4/MissingRemoteId-4.tar.bz2"}
{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "pypi", "value": "MissingRemoteId", "uri": "https://files.pythonhosted.org/packages/source/M/MissingRemoteId/MissingRemoteId-1.tar.gz"}
-{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "sourceforge", "value": "pkgcheck", "uri": "https://pkgcheck.sourceforge.net/"}
+{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "sourceforge", "value": "pkgcheck", "uri": "https://downloads.sourceforge.net/pkgcheck/MissingRemoteId-2.tar.gz"}
diff --git a/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-2.ebuild b/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-2.ebuild
index ed226b8e..2ee1bda2 100644
--- a/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-2.ebuild
+++ b/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-2.ebuild
@@ -1,7 +1,7 @@
EAPI=7
DESCRIPTION="Check homepage"
-HOMEPAGE="https://pkgcheck.sourceforge.net/"
-SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
+HOMEPAGE="https://pkgcore.github.io/pkgcheck/"
+SRC_URI="mirror://sourceforge/pkgcheck/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-01-02 20:19 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-01-02 20:19 UTC (permalink / raw
To: gentoo-commits
commit: 4247e10d9c266ac1f6aac48b0c67f1092dde1d78
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 19:27:23 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jan 2 20:11:43 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=4247e10d
ProvidedEclassInherit: new check for inheriting provided eclases
Resolves: https://github.com/pkgcore/pkgcheck/issues/504
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/eclass.py | 103 ++++++++++++++-------
.../ProvidedEclassInherit/expected.json | 1 +
.../ProvidedEclassInherit/fix.patch | 10 ++
.../ProvidedEclassInherit-0.ebuild | 11 +++
4 files changed, 93 insertions(+), 32 deletions(-)
diff --git a/src/pkgcheck/checks/eclass.py b/src/pkgcheck/checks/eclass.py
index 5c4f205f..862dbb91 100644
--- a/src/pkgcheck/checks/eclass.py
+++ b/src/pkgcheck/checks/eclass.py
@@ -98,18 +98,36 @@ class MisplacedEclassVar(results.LineResult, results.Error):
return f"invalid pre-inherit placement, line {self.lineno}: {self.line!r}"
+class ProvidedEclassInherit(results.LineResult, results.Style):
+ """Ebuild inherits an eclass which is already provided by another eclass.
+
+ When inheriting an eclass which declares ``@PROVIDES``, those referenced
+ eclasses are guaranteed to be provided by the eclass. Therefore, inheriting
+ them in ebuilds is redundant and should be removed.
+ """
+
+ def __init__(self, provider, **kwargs):
+ super().__init__(**kwargs)
+ self.provider = provider
+
+ @property
+ def desc(self):
+ return f"line {self.lineno}: redundant eclass inherit {self.line!r}, provided by {self.provider!r}"
+
+
class EclassUsageCheck(Check):
"""Scan packages for various eclass-related issues."""
_source = sources.EbuildParseRepoSource
known_results = frozenset(
- [
+ {
DeprecatedEclass,
DeprecatedEclassVariable,
DeprecatedEclassFunction,
DuplicateEclassInherit,
MisplacedEclassVar,
- ]
+ ProvidedEclassInherit,
+ }
)
required_addons = (addons.eclass.EclassAddon,)
@@ -118,15 +136,16 @@ class EclassUsageCheck(Check):
self.deprecated_eclasses = eclass_addon.deprecated
self.eclass_cache = eclass_addon.eclasses
- def check_pre_inherits(self, pkg, inherits):
+ def check_pre_inherits(self, pkg, inherits: list[tuple[list[str], int]]):
"""Check for invalid @PRE_INHERIT variable placement."""
- pre_inherits = {}
# determine if any inherited eclasses have @PRE_INHERIT variables
- for eclasses, lineno in inherits:
- for eclass in eclasses:
- for var in self.eclass_cache[eclass].variables:
- if var.pre_inherit:
- pre_inherits[var.name] = lineno
+ pre_inherits = {
+ var.name: lineno
+ for eclasses, lineno in inherits
+ for eclass in eclasses
+ for var in self.eclass_cache[eclass].variables
+ if var.pre_inherit
+ }
# scan for any misplaced @PRE_INHERIT variables
if pre_inherits:
@@ -137,22 +156,23 @@ class EclassUsageCheck(Check):
line = pkg.node_str(node)
yield MisplacedEclassVar(var_name, line=line, lineno=lineno + 1, pkg=pkg)
- def check_deprecated_variables(self, pkg, inherits):
- """Check for usage of @DEPRECATED variables or functions."""
- deprecated = {}
+ def check_deprecated_variables(self, pkg, inherits: list[tuple[list[str], int]]):
+ """Check for usage of @DEPRECATED variables."""
# determine if any inherited eclasses have @DEPRECATED variables
- for eclasses, _ in inherits:
- for eclass in eclasses:
- for var in self.eclass_cache[eclass].variables:
- if var.deprecated:
- deprecated[var.name] = var.deprecated
+ deprecated = {
+ var.name: var.deprecated
+ for eclasses, _ in inherits
+ for eclass in eclasses
+ for var in self.eclass_cache[eclass].variables
+ if var.deprecated
+ }
# scan for usage of @DEPRECATED variables
if deprecated:
for node, _ in bash.var_query.captures(pkg.tree.root_node):
var_name = pkg.node_str(node)
- lineno, _colno = node.start_point
if var_name in deprecated:
+ lineno, _colno = node.start_point
line = pkg.node_str(node)
replacement = deprecated[var_name]
if not isinstance(replacement, str):
@@ -161,22 +181,23 @@ class EclassUsageCheck(Check):
var_name, replacement, line=line, lineno=lineno + 1, pkg=pkg
)
- def check_deprecated_functions(self, pkg, inherits):
- """Check for usage of @DEPRECATED variables or functions."""
- deprecated = {}
- # determine if any inherited eclasses have @DEPRECATED variables or functions
- for eclasses, _ in inherits:
- for eclass in eclasses:
- for func in self.eclass_cache[eclass].functions:
- if func.deprecated:
- deprecated[func.name] = func.deprecated
+ def check_deprecated_functions(self, pkg, inherits: list[tuple[list[str], int]]):
+ """Check for usage of @DEPRECATED functions."""
+ # determine if any inherited eclasses have @DEPRECATED functions
+ deprecated = {
+ func.name: func.deprecated
+ for eclasses, _ in inherits
+ for eclass in eclasses
+ for func in self.eclass_cache[eclass].functions
+ if func.deprecated
+ }
# scan for usage of @DEPRECATED functions
if deprecated:
for node, _ in bash.cmd_query.captures(pkg.tree.root_node):
func_name = pkg.node_str(node.child_by_field_name("name"))
- lineno, _colno = node.start_point
if func_name in deprecated:
+ lineno, _colno = node.start_point
line = pkg.node_str(node)
replacement = deprecated[func_name]
if not isinstance(replacement, str):
@@ -185,10 +206,22 @@ class EclassUsageCheck(Check):
func_name, replacement, line=line, lineno=lineno + 1, pkg=pkg
)
+ def check_provided_eclasses(self, pkg, inherits: list[tuple[list[str], int]]):
+ """Check for usage of eclasses (i.e. redundant inherits) that are
+ provided by another inherited eclass."""
+ provided_eclasses = {
+ provided: (eclass, lineno + 1)
+ for eclasses, lineno in inherits
+ for eclass in eclasses
+ for provided in pkg.inherit.intersection(self.eclass_cache[eclass].provides)
+ }
+ for provided, (eclass, lineno) in provided_eclasses.items():
+ yield ProvidedEclassInherit(eclass, pkg=pkg, line=provided, lineno=lineno)
+
def feed(self, pkg):
if pkg.inherit:
inherited = set()
- inherits = []
+ inherits: list[tuple[list[str], int]] = []
for node, _ in bash.cmd_query.captures(pkg.tree.root_node):
name = pkg.node_str(node.child_by_field_name("name"))
if name == "inherit":
@@ -207,6 +240,7 @@ class EclassUsageCheck(Check):
eclass, line=call, lineno=lineno + 1, pkg=pkg
)
+ yield from self.check_provided_eclasses(pkg, inherits)
# verify @PRE_INHERIT variable placement
yield from self.check_pre_inherits(pkg, inherits)
# verify @DEPRECATED variables or functions
@@ -281,7 +315,7 @@ class EclassParseCheck(Check):
for var_node, _ in bash.var_query.captures(func_node):
var_name = eclass.node_str(var_node)
if var_name in variables:
- lineno, colno = var_node.start_point
+ lineno, _colno = var_node.start_point
usage[var_name].add(lineno + 1)
for var, lines in sorted(usage.items()):
yield EclassVariableScope(
@@ -369,7 +403,12 @@ class EclassCheck(Check):
_source = sources.EclassRepoSource
known_results = frozenset(
- [EclassBashSyntaxError, EclassDocError, EclassDocMissingFunc, EclassDocMissingVar]
+ [
+ EclassBashSyntaxError,
+ EclassDocError,
+ EclassDocMissingFunc,
+ EclassDocMissingVar,
+ ]
)
def __init__(self, *args):
@@ -393,7 +432,7 @@ class EclassCheck(Check):
lineno = 0
error = []
for line in p.stderr.splitlines():
- path, line, msg = line.split(": ", 2)
+ _path, line, msg = line.split(": ", 2)
lineno = line[5:]
error.append(msg.strip("\n"))
error = ": ".join(error)
diff --git a/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/expected.json b/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/expected.json
new file mode 100644
index 00000000..397c0644
--- /dev/null
+++ b/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/expected.json
@@ -0,0 +1 @@
+{"__class__": "ProvidedEclassInherit", "category": "EclassUsageCheck", "package": "ProvidedEclassInherit", "version": "0", "line": "inherit", "lineno": 2, "provider": "deep-provided-inherit"}
diff --git a/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/fix.patch b/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/fix.patch
new file mode 100644
index 00000000..607e8caf
--- /dev/null
+++ b/testdata/data/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/fix.patch
@@ -0,0 +1,10 @@
+diff -Naur eclass/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild fixed/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild
+--- eclass/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild 2021-05-23 20:23:16.423009026 -0600
++++ fixed/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild 2021-05-23 20:23:43.734588313 -0600
+@@ -1,5 +1,5 @@
+ EAPI=7
+-inherit inherit deep-provided-inherit
++inherit deep-provided-inherit
+ DESCRIPTION="Ebuild inheriting provided eclass"
+ HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+ SLOT="0"
diff --git a/testdata/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild b/testdata/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild
new file mode 100644
index 00000000..cd8585ea
--- /dev/null
+++ b/testdata/repos/eclass/EclassUsageCheck/ProvidedEclassInherit/ProvidedEclassInherit-0.ebuild
@@ -0,0 +1,11 @@
+EAPI=7
+inherit inherit deep-provided-inherit
+DESCRIPTION="Ebuild inheriting provided eclass"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+SLOT="0"
+LICENSE="BSD"
+
+src_prepare() {
+ inherit_public_func
+ deep-provided-inherit_public_func
+}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-01-14 20:29 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-01-14 20:29 UTC (permalink / raw
To: gentoo-commits
commit: 357f6104cb08913d840b749659096eeb2d0fa325
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 12 20:40:27 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 12 20:40:27 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=357f6104
EclassUsageCheck: check for setting user variables in ebuilds
Check ebuilds for overriding eclass' user variables.
Resolves: https://github.com/pkgcore/pkgcheck/issues/512
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/eclass.py | 37 +++++++++++++++++++++-
.../EclassUserVariableUsage/expected.json | 1 +
.../EclassUserVariableUsage-0.ebuild | 12 +++++++
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/src/pkgcheck/checks/eclass.py b/src/pkgcheck/checks/eclass.py
index 862dbb91..935ed960 100644
--- a/src/pkgcheck/checks/eclass.py
+++ b/src/pkgcheck/checks/eclass.py
@@ -47,6 +47,18 @@ class DeprecatedEclassVariable(results.LineResult, results.Warning):
return f"uses deprecated variable on line {self.lineno}: {self.variable} ({replacement})"
+class EclassUserVariableUsage(results.LineResult, results.Warning):
+ """Package uses a user variable from an eclass."""
+
+ def __init__(self, eclass, **kwargs):
+ super().__init__(**kwargs)
+ self.eclass = eclass
+
+ @property
+ def desc(self):
+ return f"line {self.lineno}: uses user variable {self.line!r} from eclass {self.eclass!r}"
+
+
class DeprecatedEclassFunction(results.LineResult, results.Warning):
"""Package uses a deprecated function from an eclass."""
@@ -125,6 +137,7 @@ class EclassUsageCheck(Check):
DeprecatedEclassVariable,
DeprecatedEclassFunction,
DuplicateEclassInherit,
+ EclassUserVariableUsage,
MisplacedEclassVar,
ProvidedEclassInherit,
}
@@ -156,6 +169,27 @@ class EclassUsageCheck(Check):
line = pkg.node_str(node)
yield MisplacedEclassVar(var_name, line=line, lineno=lineno + 1, pkg=pkg)
+ def check_user_variables(self, pkg: bash.ParseTree, inherits: list[tuple[list[str], int]]):
+ """Check for usage of @USER_VARIABLE variables."""
+ # determine if any inherited eclasses have @USER_VARIABLE variables
+ user_variables = {
+ var.name: eclass
+ for eclasses, _ in inherits
+ for eclass in eclasses
+ for var in self.eclass_cache[eclass].variables
+ if var.user_variable
+ }
+
+ # scan for usage of @USER_VARIABLE variables
+ if user_variables:
+ for node, _ in bash.var_assign_query.captures(pkg.tree.root_node):
+ var_name = pkg.node_str(node.child_by_field_name("name"))
+ if var_name in user_variables:
+ lineno, _colno = node.start_point
+ yield EclassUserVariableUsage(
+ user_variables[var_name], line=var_name, lineno=lineno + 1, pkg=pkg
+ )
+
def check_deprecated_variables(self, pkg, inherits: list[tuple[list[str], int]]):
"""Check for usage of @DEPRECATED variables."""
# determine if any inherited eclasses have @DEPRECATED variables
@@ -220,7 +254,7 @@ class EclassUsageCheck(Check):
def feed(self, pkg):
if pkg.inherit:
- inherited = set()
+ inherited: set[str] = set()
inherits: list[tuple[list[str], int]] = []
for node, _ in bash.cmd_query.captures(pkg.tree.root_node):
name = pkg.node_str(node.child_by_field_name("name"))
@@ -241,6 +275,7 @@ class EclassUsageCheck(Check):
)
yield from self.check_provided_eclasses(pkg, inherits)
+ yield from self.check_user_variables(pkg, inherits)
# verify @PRE_INHERIT variable placement
yield from self.check_pre_inherits(pkg, inherits)
# verify @DEPRECATED variables or functions
diff --git a/testdata/data/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/expected.json b/testdata/data/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/expected.json
new file mode 100644
index 00000000..03b11f6a
--- /dev/null
+++ b/testdata/data/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/expected.json
@@ -0,0 +1 @@
+{"__class__": "EclassUserVariableUsage", "category": "EclassUsageCheck", "package": "EclassUserVariableUsage", "version": "0", "line": "EBZR_STORE_DIR", "lineno": 8, "eclass": "unquotedvariable"}
diff --git a/testdata/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/EclassUserVariableUsage-0.ebuild b/testdata/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/EclassUserVariableUsage-0.ebuild
new file mode 100644
index 00000000..dae4c7d1
--- /dev/null
+++ b/testdata/repos/eclass/EclassUsageCheck/EclassUserVariableUsage/EclassUserVariableUsage-0.ebuild
@@ -0,0 +1,12 @@
+EAPI=8
+inherit unquotedvariable
+DESCRIPTION="Ebuild with user variable override"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+SLOT="0"
+LICENSE="BSD"
+
+EBZR_STORE_DIR="/var/tmp/portage" # FAIL
+
+src_prepare() {
+ echo "${EBZR_STORE_DIR}" # ok
+}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-01-18 5:19 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-01-18 5:19 UTC (permalink / raw
To: gentoo-commits
commit: bca5e4880d0bbe1b4a34fc0185885bbbcca76230
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 16 20:09:10 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jan 16 20:09:10 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=bca5e488
ProfilesCheck: check USE_EXPAND_VALUES_* in make.defaults
Related: https://github.com/pkgcore/pkgcheck/issues/524
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/profiles.py | 32 ++++++++++++++++++++++
.../UnknownProfileUseExpand/expected.json | 1 +
.../UnknownProfileUseExpandValue/expected.json | 2 ++
.../UnknownProfileUseExpandValue/fix.patch | 13 +++++++++
4 files changed, 48 insertions(+)
diff --git a/src/pkgcheck/checks/profiles.py b/src/pkgcheck/checks/profiles.py
index 7929a10c..ed6d1263 100644
--- a/src/pkgcheck/checks/profiles.py
+++ b/src/pkgcheck/checks/profiles.py
@@ -110,6 +110,22 @@ class UnknownProfileUseExpand(results.ProfilesResult, results.Warning):
return f"{self.path!r}: unknown USE_EXPAND group{s} in {self.var!r}: {groups}"
+class UnknownProfileUseExpandValue(results.ProfilesResult, results.Warning):
+ """Profile defines unknown default values for USE_EXPAND group."""
+
+ def __init__(self, path: str, group: str, values: Iterable[str]):
+ super().__init__()
+ self.path = path
+ self.group = group
+ self.values = tuple(values)
+
+ @property
+ def desc(self):
+ s = pluralism(self.values)
+ values = ", ".join(self.values)
+ return f"{self.path!r}: unknown value{s} for {self.group!r}: {values}"
+
+
class UnknownProfileArch(results.ProfilesResult, results.Warning):
"""Profile includes unknown ARCH."""
@@ -168,6 +184,7 @@ class ProfilesCheck(Check):
UnknownProfileUse,
UnknownProfilePackageKeywords,
UnknownProfileUseExpand,
+ UnknownProfileUseExpandValue,
UnknownProfileArch,
ProfileWarning,
ProfileError,
@@ -313,6 +330,21 @@ class ProfilesCheck(Check):
yield UnknownProfileUseExpand(
pjoin(node.name, filename), use_group, sorted(unknown)
)
+ for key, val in vals.items():
+ if key.startswith("USE_EXPAND_VALUES_"):
+ use_group = key[18:]
+ if use_group in implicit_use_expands:
+ continue
+ elif allowed_values := self.use_expand_groups.get(use_group, None):
+ if unknown := set(val.split()) - allowed_values:
+ yield UnknownProfileUseExpandValue(
+ pjoin(node.name, filename), key, sorted(unknown)
+ )
+ else:
+ yield UnknownProfileUseExpand(pjoin(node.name, filename), key, [use_group])
+ for key in vals.keys() & self.use_expand_groups.keys():
+ if unknown := set(vals.get(key, "").split()) - self.use_expand_groups[key]:
+ yield UnknownProfileUseExpandValue(pjoin(node.name, filename), key, sorted(unknown))
if arch := vals.get("ARCH", None):
if arch not in self.keywords.arches:
yield UnknownProfileArch(pjoin(node.name, filename), arch)
diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpand/expected.json b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpand/expected.json
index 5817a2e1..8e465239 100644
--- a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpand/expected.json
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpand/expected.json
@@ -1,2 +1,3 @@
{"__class__": "UnknownProfileUseExpand", "path": "unknown_use/make.defaults", "var": "USE_EXPAND", "groups": ["PYTHON_SINGLE_TARGET"]}
{"__class__": "UnknownProfileUseExpand", "path": "unknown_use/make.defaults", "var": "USE_EXPAND_UNPREFIXED", "groups": ["LUA_TARGETS"]}
+{"__class__": "UnknownProfileUseExpand", "path": "unknown_use/make.defaults", "var": "USE_EXPAND_VALUES_LUA_TARGETS", "groups": ["LUA_TARGETS"]}
diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/expected.json b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/expected.json
new file mode 100644
index 00000000..6fcd75f7
--- /dev/null
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/expected.json
@@ -0,0 +1,2 @@
+{"__class__": "UnknownProfileUseExpandValue", "path": "unknown_use/make.defaults", "group": "PYTHON_TARGETS", "values": ["python3_9"]}
+{"__class__": "UnknownProfileUseExpandValue", "path": "unknown_use/make.defaults", "group": "USE_EXPAND_VALUES_PYTHON_TARGETS", "values": ["python3_9"]}
diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/fix.patch b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/fix.patch
new file mode 100644
index 00000000..0d26d5df
--- /dev/null
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUseExpandValue/fix.patch
@@ -0,0 +1,13 @@
+diff -Naur profiledir/profiles/unknown_use/make.defaults fixed/profiles/unknown_use/make.defaults
+diff --git a/testdata/repos/profiledir/profiles/unknown_use/make.defaults b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
+index 6d789215..2c98efd3 100644
+--- profiledir/profiles/unknown_use/make.defaults
++++ fixed/profiles/unknown_use/make.defaults
+@@ -5,5 +5,5 @@
+ USE_EXPAND_UNPREFIXED="ARCH LUA_TARGETS PYTHON_TARGETS"
+ USE_EXPAND_VALUES_ARCH="amd64 x86"
+ USE_EXPAND_VALUES_LUA_TARGETS="lua5_1"
+-USE_EXPAND_VALUES_PYTHON_TARGETS="python3_9 python3_10"
+-PYTHON_TARGETS="python3_9 python3_10"
++USE_EXPAND_VALUES_PYTHON_TARGETS="python3_10"
++PYTHON_TARGETS="python3_10"
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-01-18 5:19 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-01-18 5:19 UTC (permalink / raw
To: gentoo-commits
commit: 9e43d725ce4c2049e53e9df444b47c388bf98573
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 15 20:31:16 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 20:31:16 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=9e43d725
ProfilesCheck: check for unknown USE & IUSE_IMPLICIT in make.defaults
Related: https://github.com/pkgcore/pkgcheck/issues/524
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/profiles.py | 7 +++++++
.../repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json | 1 +
.../repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch | 4 +++-
testdata/repos/profiledir/profiles/unknown_use/make.defaults | 2 ++
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/pkgcheck/checks/profiles.py b/src/pkgcheck/checks/profiles.py
index 00d7c069..6d113519 100644
--- a/src/pkgcheck/checks/profiles.py
+++ b/src/pkgcheck/checks/profiles.py
@@ -290,6 +290,13 @@ class ProfilesCheck(Check):
@verify_files(("make.defaults", "make_defaults"))
def _make_defaults(self, filename: str, node, vals: dict[str, str]):
+ if use_flags := {
+ use.removeprefix("-")
+ for use_group in ("USE", "IUSE_IMPLICIT")
+ for use in vals.get(use_group, "").split()
+ }:
+ if unknown := use_flags - self.available_iuse:
+ yield UnknownProfileUse(pjoin(node.name, filename), sorted(unknown))
if defined := set(vals.get("USE_EXPAND", "").split()):
if unknown := defined - self.use_expand_groups:
yield UnknownProfileUseExpand(pjoin(node.name, filename), sorted(unknown))
diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
index 36f7f55c..b7b1c988 100644
--- a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
@@ -1,3 +1,4 @@
+{"__class__": "UnknownProfileUse", "path": "unknown_use/make.defaults", "flags": ["defaults_iuse_implicit", "defaults_use"]}
{"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use/use.force", "flags": ["-use_force"]}
{"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use/use.stable.force", "flags": ["use_stable_force"]}
{"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use_mask/use.mask", "flags": ["-use_mask"]}
diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
index 1541f627..d4003eb4 100644
--- a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
@@ -1,9 +1,11 @@
diff -Naur profiledir/profiles/use.desc fixed/profiles/use.desc
--- profiledir/profiles/use.desc 2020-11-23 10:54:01.018477444 -0700
+++ fixed/profiles/use.desc 2020-11-23 11:54:08.071178614 -0700
-@@ -1 +1,5 @@
+@@ -1 +1,7 @@
used - used global flag
+use_force - use.force
+use_mask - use.mask
+use_stable_force - use.stable.force
+use_stable_mask - use.stable.mask
++defaults_use - make.defaults USE
++defaults_iuse_implicit - make.defaults IUSE_IMPLICIT
diff --git a/testdata/repos/profiledir/profiles/unknown_use/make.defaults b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
new file mode 100644
index 00000000..4699667b
--- /dev/null
+++ b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
@@ -0,0 +1,2 @@
+USE="defaults_use used"
+IUSE_IMPLICIT="defaults_iuse_implicit used"
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-01-30 19:07 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-01-30 19:07 UTC (permalink / raw
To: gentoo-commits
commit: 088136ddc8008856eb6c3d3e432e15af8d704ba3
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 26 18:24:50 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 26 18:24:50 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=088136dd
InvalidMetadataRestrict: check for invalid restricts in metadata.xml
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/metadata_xml.py | 34 ++++++++++++++++++++++
.../InvalidMetadataRestrict/expected.json | 1 +
.../InvalidMetadataRestrict-0.ebuild | 8 +++++
.../InvalidMetadataRestrict/metadata.xml | 10 +++++++
4 files changed, 53 insertions(+)
diff --git a/src/pkgcheck/checks/metadata_xml.py b/src/pkgcheck/checks/metadata_xml.py
index 0fcc31ac..adba0bdb 100644
--- a/src/pkgcheck/checks/metadata_xml.py
+++ b/src/pkgcheck/checks/metadata_xml.py
@@ -294,6 +294,19 @@ class InvalidRemoteID(results.PackageResult, results.Warning):
)
+class InvalidMetadataRestrict(results.PackageResult, results.Error):
+ """Invalid package restrictions used in metadata.xml."""
+
+ def __init__(self, restrict: str, msg: str, **kwargs):
+ super().__init__(**kwargs)
+ self.restrict = restrict
+ self.msg = msg
+
+ @property
+ def desc(self):
+ return f"metadata.xml: invalid package restrictions {self.restrict!r}: {self.msg}"
+
+
class _XmlBaseCheck(Check):
"""Base class for metadata.xml scans."""
@@ -433,6 +446,7 @@ class PackageMetadataXmlCheck(_XmlBaseCheck):
NonexistentProjectMaintainer,
WrongMaintainerType,
InvalidRemoteID,
+ InvalidMetadataRestrict,
]
)
@@ -534,6 +548,26 @@ class PackageMetadataXmlCheck(_XmlBaseCheck):
msg = "metadata.xml longdescription is too short"
yield RedundantLongDescription(msg, pkg=pkg)
+ def _check_restricts(self, pkg, loc, doc):
+ restricts = (
+ c.get("restrict")
+ for path in ("maintainer", "use/flag")
+ for c in doc.xpath(f"/pkgmetadata/{path}[string(@restrict)]")
+ )
+ for restrict_str in restricts:
+ try:
+ restrict = atom(restrict_str, eapi="0")
+ if restrict.key != pkg.key:
+ yield InvalidMetadataRestrict(
+ restrict_str, "references another package", pkg=pkg
+ )
+ if restrict.use:
+ yield InvalidMetadataRestrict(
+ restrict_str, "USE-conditionals are prohibited", pkg=pkg
+ )
+ except MalformedAtom as exc:
+ yield InvalidMetadataRestrict(restrict_str, exc, pkg=pkg)
+
def _check_remote_id(self, pkg, loc, doc):
for u in pkg.upstreams:
# empty values are already reported as PkgMetadataXmlEmptyElement
diff --git a/testdata/data/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/expected.json b/testdata/data/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/expected.json
new file mode 100644
index 00000000..aca61195
--- /dev/null
+++ b/testdata/data/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/expected.json
@@ -0,0 +1 @@
+{"__class__": "InvalidMetadataRestrict", "category": "PackageMetadataXmlCheck", "package": "InvalidMetadataRestrict", "restrict": "<=PackageMetadataXmlCheck2/InvalidMetadataRestrict-5", "msg": "references another package"}
diff --git a/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/InvalidMetadataRestrict-0.ebuild b/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/InvalidMetadataRestrict-0.ebuild
new file mode 100644
index 00000000..eb5d8297
--- /dev/null
+++ b/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/InvalidMetadataRestrict-0.ebuild
@@ -0,0 +1,8 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+DESCRIPTION="Package metadata.xml with invalid restrict"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+SLOT="0"
+LICENSE="BSD"
+IUSE="flag1"
diff --git a/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/metadata.xml b/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/metadata.xml
new file mode 100644
index 00000000..52cd01df
--- /dev/null
+++ b/testdata/repos/gentoo/PackageMetadataXmlCheck/InvalidMetadataRestrict/metadata.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person" restrict="<=PackageMetadataXmlCheck2/InvalidMetadataRestrict-5">
+ <email>random.gentoo.dev@gentoo.org</email>
+ </maintainer>
+ <use>
+ <flag name="flag1" restrict="<=PackageMetadataXmlCheck/InvalidMetadataRestrict-5">Some explanation</flag>
+ </use>
+</pkgmetadata>
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-02-03 13:03 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-02-03 13:03 UTC (permalink / raw
To: gentoo-commits
commit: 87226810dca088b8eec5d03639b3d830293c82aa
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 31 18:00:51 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 3 13:03:35 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=87226810
PythonCheck: check for missing scm dep when needed
Resolves: https://github.com/pkgcore/pkgcheck/issues/537
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/python.py | 37 ++++++++++++++++++++--
.../PythonMissingSCMDependency/expected.json | 1 +
.../PythonMissingSCMDependency/fix.patch | 8 +++++
.../PythonMissingSCMDependency-0.ebuild | 13 ++++++++
.../PythonMissingSCMDependency/metadata.xml | 4 +++
5 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 2b20ee93..11ebc1e1 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -1,6 +1,7 @@
-from collections import defaultdict
import itertools
import re
+from collections import defaultdict
+from operator import attrgetter
from pkgcore import fetch
from pkgcore.ebuild.atom import atom
@@ -222,6 +223,20 @@ class PythonAnyMismatchedDepHasVersionCheck(results.VersionResult, results.Warni
return f"{self.dep_category}: missing check for {self.dep_atom}[{use_flags}] in {self.location!r}"
+class PythonMissingSCMDependency(results.VersionResult, results.Warning):
+ """Package is missing BDEPEND on setuptools_scm or alike.
+
+ Packages which define ``SETUPTOOLS_SCM_PRETEND_VERSION`` should BDEPEND
+ on ``dev-python/setuptools_scm`` or a similar package [#]_.
+
+ .. [#] https://projects.gentoo.org/python/guide/distutils.html#setuptools-scm-flit-scm-hatch-vcs-and-snapshots
+ """
+
+ desc = (
+ "defines SETUPTOOLS_SCM_PRETEND_VERSION but is missing BDEPEND on setuptools_scm or alike"
+ )
+
+
class PythonCheck(Check):
"""Python eclass checks.
@@ -242,6 +257,7 @@ class PythonCheck(Check):
PythonHasVersionMissingPythonUseDep,
PythonAnyMismatchedUseHasVersionCheck,
PythonAnyMismatchedDepHasVersionCheck,
+ PythonMissingSCMDependency,
]
)
@@ -263,6 +279,14 @@ class PythonCheck(Check):
"python-r1": "python_gen_any_dep",
}
+ setuptools_scm = frozenset(
+ {
+ "dev-python/setuptools_scm",
+ "dev-python/flit_scm",
+ "dev-python/hatch-vcs",
+ }
+ )
+
def scan_tree_recursively(self, deptree, expected_cls):
for x in deptree:
if not isinstance(x, expected_cls):
@@ -319,6 +343,7 @@ class PythonCheck(Check):
"""
has_distutils_optional = None
has_distutils_deps = False
+ uses_setuptools_scm = False
pep517_value = None
for var_node, _ in bash.var_assign_query.captures(pkg.tree.root_node):
@@ -328,21 +353,29 @@ class PythonCheck(Check):
has_distutils_optional = True
elif var_name == "DISTUTILS_USE_PEP517":
pep517_value = pkg.node_str(var_node.children[-1])
+ elif var_name == "SETUPTOOLS_SCM_PRETEND_VERSION":
+ uses_setuptools_scm = True
if "DISTUTILS_DEPS" in pkg.node_str(var_node.parent):
# If they're referencing the eclass' dependency variable,
# there's nothing for us to do anyway.
has_distutils_deps = True
+ bdepends = frozenset(map(attrgetter("key"), iflatten_instance(pkg.bdepend, atom)))
+
if pep517_value is None:
yield DistutilsNonPEP517Build(pkg=pkg)
elif has_distutils_optional and not has_distutils_deps and pep517_value != "no":
# We always need BDEPEND for these if != no.
# We are looking for USE-conditional on appropriate target
# flag, with dep on dev-python/gpep517.
- if "dev-python/gpep517" not in iflatten_instance(pkg.bdepend, atom):
+ if "dev-python/gpep517" not in bdepends:
yield PythonMissingDeps("BDEPEND", pkg=pkg, dep_value="DISTUTILS_DEPS")
+ if uses_setuptools_scm:
+ if not self.setuptools_scm.intersection(bdepends):
+ yield PythonMissingSCMDependency(pkg=pkg)
+
@staticmethod
def _prepare_deps(deps: str):
try:
diff --git a/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/expected.json b/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/expected.json
new file mode 100644
index 00000000..9297a0d5
--- /dev/null
+++ b/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/expected.json
@@ -0,0 +1 @@
+{"__class__": "PythonMissingSCMDependency", "category": "PythonCheck", "package": "PythonMissingSCMDependency", "version": "0"}
diff --git a/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/fix.patch b/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/fix.patch
new file mode 100644
index 00000000..94f8de26
--- /dev/null
+++ b/testdata/data/repos/python/PythonCheck/PythonMissingSCMDependency/fix.patch
@@ -0,0 +1,8 @@
+--- python/PythonCheck/PythonMissingSCMDependency/PythonMissingSCMDependency-0.ebuild
++++ fixed/PythonCheck/PythonMissingSCMDependency/PythonMissingSCMDependency-0.ebuild
+@@ -10,4 +10,5 @@
+ LICENSE="BSD"
+ SLOT="0"
+
++BDEPEND="dev-python/hatch-vcs[${PYTHON_USEDEP}]"
+ export SETUPTOOLS_SCM_PRETEND_VERSION=${PV}
diff --git a/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/PythonMissingSCMDependency-0.ebuild b/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/PythonMissingSCMDependency-0.ebuild
new file mode 100644
index 00000000..79a8a8df
--- /dev/null
+++ b/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/PythonMissingSCMDependency-0.ebuild
@@ -0,0 +1,13 @@
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_10 )
+
+inherit distutils-r1
+
+DESCRIPTION="Ebuild with missing dep on scm"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+LICENSE="BSD"
+SLOT="0"
+
+export SETUPTOOLS_SCM_PRETEND_VERSION=${PV}
diff --git a/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/metadata.xml b/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/metadata.xml
new file mode 100644
index 00000000..097975e3
--- /dev/null
+++ b/testdata/repos/python/PythonCheck/PythonMissingSCMDependency/metadata.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+</pkgmetadata>
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-04-24 16:43 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-04-24 16:43 UTC (permalink / raw
To: gentoo-commits
commit: fdcf83d0811019e0a465006493fe4acad77043da
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 24 16:39:20 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Apr 24 16:39:20 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=fdcf83d0
MissingEAPIBlankLine: make it optional
Requested by multiple devs, maybe in future we would improve logic, and
un-optional it.
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/whitespace.py | 29 ++++++++++++++++------
.../MissingEAPIBlankLine/expected.json | 1 -
.../WhitespaceCheck/MissingEAPIBlankLine/fix.patch | 9 -------
.../MissingEAPIBlankLine-0.ebuild | 5 ----
tests/checks/test_whitespace.py | 18 ++++++++++++++
5 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/src/pkgcheck/checks/whitespace.py b/src/pkgcheck/checks/whitespace.py
index 31667f9c..a853e0b0 100644
--- a/src/pkgcheck/checks/whitespace.py
+++ b/src/pkgcheck/checks/whitespace.py
@@ -4,7 +4,7 @@ import re
from typing import NamedTuple
from .. import results, sources
-from . import Check
+from . import Check, OptionalCheck
class _Whitespace(results.LinesResult, results.Style):
@@ -131,7 +131,6 @@ class WhitespaceCheck(Check):
TrailingEmptyLine,
NoFinalNewline,
BadWhitespaceCharacter,
- MissingEAPIBlankLine,
}
)
@@ -148,14 +147,8 @@ class WhitespaceCheck(Check):
leading = []
indent = []
double_empty = []
- eapi_lineno = None
for lineno, line in enumerate(pkg.lines, 1):
- if line.startswith("EAPI="):
- eapi_lineno = lineno
- elif eapi_lineno is not None and lineno == eapi_lineno + 1 and line != "\n":
- yield MissingEAPIBlankLine(pkg=pkg)
-
for match in self.bad_whitespace_regex.finditer(line):
yield BadWhitespaceCharacter(
repr(match.group("char")),
@@ -191,3 +184,23 @@ class WhitespaceCheck(Check):
# Dealing with empty ebuilds is just paranoia
if pkg.lines and not pkg.lines[-1].endswith("\n"):
yield NoFinalNewline(pkg=pkg)
+
+
+class MissingWhitespaceCheck(OptionalCheck):
+ """Scan ebuild for missing whitespace."""
+
+ _source = sources.EbuildFileRepoSource
+ known_results = frozenset(
+ {
+ MissingEAPIBlankLine,
+ }
+ )
+
+ def feed(self, pkg):
+ eapi_lineno = None
+
+ for lineno, line in enumerate(pkg.lines, 1):
+ if line.startswith("EAPI="):
+ eapi_lineno = lineno
+ elif eapi_lineno is not None and lineno == eapi_lineno + 1 and line != "\n":
+ yield MissingEAPIBlankLine(pkg=pkg)
diff --git a/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/expected.json b/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/expected.json
deleted file mode 100644
index d0630087..00000000
--- a/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/expected.json
+++ /dev/null
@@ -1 +0,0 @@
-{"__class__": "MissingEAPIBlankLine", "category": "WhitespaceCheck", "package": "MissingEAPIBlankLine", "version": "0"}
diff --git a/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/fix.patch b/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/fix.patch
deleted file mode 100644
index e6b838e3..00000000
--- a/testdata/data/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/fix.patch
+++ /dev/null
@@ -1,9 +0,0 @@
-diff -Naur standalone/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild fixed/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild
---- standalone/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild
-+++ fixed/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild
-@@ -1,4 +1,5 @@
- EAPI=7
-+
- DESCRIPTION="Ebuild is missing blank line after EAPI"
- HOMEPAGE="https://github.com/pkgcore/pkgcheck"
- SLOT="0"
diff --git a/testdata/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild b/testdata/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild
deleted file mode 100644
index fc5a6781..00000000
--- a/testdata/repos/standalone/WhitespaceCheck/MissingEAPIBlankLine/MissingEAPIBlankLine-0.ebuild
+++ /dev/null
@@ -1,5 +0,0 @@
-EAPI=7
-DESCRIPTION="Ebuild is missing blank line after EAPI"
-HOMEPAGE="https://github.com/pkgcore/pkgcheck"
-SLOT="0"
-LICENSE="BSD"
diff --git a/tests/checks/test_whitespace.py b/tests/checks/test_whitespace.py
index f90495b6..e6324d77 100644
--- a/tests/checks/test_whitespace.py
+++ b/tests/checks/test_whitespace.py
@@ -150,3 +150,21 @@ class TestMultipleChecks(WhitespaceCheckTest):
reports = self.assertReports(self.check, fake_pkg)
assert len(reports) == 4
+
+
+class TestMissingWhitespaceCheck(misc.ReportTestCase):
+ check_kls = whitespace.MissingWhitespaceCheck
+ check = whitespace.MissingWhitespaceCheck(None)
+
+ def test_it(self):
+ fake_src = [
+ "# This is a comment\n",
+ "# This is a comment\n",
+ "# This is a comment, and no blank line before EAPI\n",
+ "EAPI=8\n",
+ "inherit fake\n", # no blank line after EAPI=
+ ]
+ fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src)
+
+ r = self.assertReport(self.check, fake_pkg)
+ assert isinstance(r, whitespace.MissingEAPIBlankLine)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2023-09-23 15:10 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2023-09-23 15:10 UTC (permalink / raw
To: gentoo-commits
commit: 64ea04886ae7769db53bef175652531af240fb83
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 23 10:35:09 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Sep 23 10:35:09 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=64ea0488
EmptyGlobalAssignment: check for empty global assignments
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/codingstyle.py | 21 ++++++++++++++++++++-
.../EmptyGlobalAssignment/expected.json | 3 +++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py
index 0e2188db..6f1e3b7f 100644
--- a/src/pkgcheck/checks/codingstyle.py
+++ b/src/pkgcheck/checks/codingstyle.py
@@ -547,6 +547,14 @@ class MultipleKeywordsLines(results.LinesResult, results.Style):
return f"KEYWORDS specified {self.lines_str}"
+class EmptyGlobalAssignment(results.LineResult, results.Style):
+ """Global scope useless empty assignment."""
+
+ @property
+ def desc(self):
+ return f"line {self.lineno}: empty global assignment: {self.line}"
+
+
def verify_vars(*variables):
"""Decorator to register raw variable verification methods."""
@@ -569,7 +577,13 @@ class MetadataVarCheck(Check):
_source = sources.EbuildParseRepoSource
known_results = frozenset(
- [HomepageInSrcUri, StaticSrcUri, ReferenceInMetadataVar, MultipleKeywordsLines]
+ {
+ HomepageInSrcUri,
+ StaticSrcUri,
+ ReferenceInMetadataVar,
+ MultipleKeywordsLines,
+ EmptyGlobalAssignment,
+ }
)
# mapping between registered variables and verification methods
@@ -644,6 +658,11 @@ class MetadataVarCheck(Check):
keywords_lines = set()
for node in pkg.global_query(bash.var_assign_query):
name = pkg.node_str(node.child_by_field_name("name"))
+ value = node.child_by_field_name("value")
+ if name in pkg.eapi.eclass_keys:
+ if not value or not pkg.node_str(value).strip("\"'"):
+ lineno, _ = node.start_point
+ yield EmptyGlobalAssignment(line=pkg.node_str(node), lineno=lineno + 1, pkg=pkg)
if name in self.known_variables:
# RHS value node should be last
val_node = node.children[-1]
diff --git a/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json
new file mode 100644
index 00000000..2e861fc0
--- /dev/null
+++ b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json
@@ -0,0 +1,3 @@
+{"__class__": "EmptyGlobalAssignment", "category": "DescriptionCheck", "package": "BadDescription", "version": "1", "line": "DESCRIPTION=\"\"", "lineno": 1}
+{"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "MultipleKeywordsLines", "version": "0", "line": "KEYWORDS=\"\"", "lineno": 8}
+{"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "ReferenceInMetadataVar", "version": "3", "line": "LICENSE=\"\"", "lineno": 5}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2024-08-01 19:41 Arthur Zamarin
0 siblings, 0 replies; 12+ messages in thread
From: Arthur Zamarin @ 2024-08-01 19:41 UTC (permalink / raw
To: gentoo-commits
commit: bd21cbc2b2fa4e7761463136c5aaf88304272e68
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 1 19:40:27 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 1 19:40:27 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=bd21cbc2
EmptyGlobalAssignment: ignore empty KEYWORDS
Resolves: https://github.com/pkgcore/pkgcheck/issues/695
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/codingstyle.py | 9 +++++++--
.../MetadataVarCheck/EmptyGlobalAssignment/expected.json | 1 -
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py
index cfc7f8da..42bd0004 100644
--- a/src/pkgcheck/checks/codingstyle.py
+++ b/src/pkgcheck/checks/codingstyle.py
@@ -634,6 +634,8 @@ class MetadataVarCheck(Check):
# mapping between registered variables and verification methods
known_variables = {}
+ empty_vars_whitelist = frozenset({"KEYWORDS"})
+
@verify_vars("HOMEPAGE", "KEYWORDS")
def _raw_text(self, var, node, value, pkg):
matches = []
@@ -710,8 +712,11 @@ class MetadataVarCheck(Check):
value_str = self.canonicalize_assign(pkg.node_str(value_node)) if value_node else ""
if name in pkg.eapi.eclass_keys:
if not value_str:
- lineno, _ = node.start_point
- yield EmptyGlobalAssignment(line=pkg.node_str(node), lineno=lineno + 1, pkg=pkg)
+ if name not in self.empty_vars_whitelist:
+ lineno, _ = node.start_point
+ yield EmptyGlobalAssignment(
+ line=pkg.node_str(node), lineno=lineno + 1, pkg=pkg
+ )
elif pkg.node_str(value_node.prev_sibling) == "=":
for var_node, _ in bash.var_query.captures(value_node):
if (
diff --git a/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json
index 7cab9376..c5c90f2d 100644
--- a/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json
+++ b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json
@@ -1,3 +1,2 @@
{"__class__": "EmptyGlobalAssignment", "category": "DescriptionCheck", "package": "BadDescription", "version": "1", "line": "DESCRIPTION=\"\"", "lineno": 1}
-{"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "MultipleKeywordsLines", "version": "0", "line": "KEYWORDS=\"\"", "lineno": 8}
{"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "ReferenceInMetadataVar", "version": "3", "line": "LICENSE=\"\"", "lineno": 4}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
@ 2024-11-22 21:35 Michał Górny
0 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2024-11-22 21:35 UTC (permalink / raw
To: gentoo-commits
commit: 3deb50dd5394ef306a911fdd37a1bf92ae658adc
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 22 15:07:02 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Nov 22 21:35:14 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=3deb50dd
python: Enforce a stricter PyPI package naming policy
Enforce a stricter package naming policy that requires using lowercase
names and hyphens over underscores. Once this change lands, I'll update
the Python Guide as well.
Previously, the policy was to permit either forcing lowercase, or to
follow upstream naming (and the name check, more liberally, was done
case-insensitively), with a note to enforce consistency across different
packages. This caused twofold problems.
Firstly, not all packages ended up following the policy for consistent
naming -- so we e.g. have flit-core but flit_scm, or flask but
Frozen-Flask. Part of the problem is that 1) PyPI packages themselves,
particularly third-party extensions, don't follow consistent naming
themselves, and 2) some PyPI packages actually get "renamed" with case
and/or hyphen changes.
Secondly, this policy makes naming less predictable. In particular,
with upstream name of "flit-scm", you don't immediately figure out it's
"flit_scm" in Gentoo, or with "PyGithub" you can't guess whether to look
for "PyGithub" or "pygithub".
The changed policy will require changes to 44 packages in Gentoo.
Closes: https://github.com/pkgcore/pkgcheck/pull/717
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
src/pkgcheck/checks/python.py | 4 ++--
.../PythonPackageNameCheck/PythonMismatchedPackageName/expected.json | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index bacbdb5a..392241b2 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -946,5 +946,5 @@ class PythonPackageNameCheck(Check):
return PROJECT_SYMBOL_NORMALIZE_RE.sub("-", project).lower()
pypi_name = pypi_remotes[0].name
- if normalize(pkg.package) != normalize(pypi_name):
- yield PythonMismatchedPackageName(pypi_name.replace(".", "-"), pkg=pkg)
+ if pkg.package != normalize(pypi_name):
+ yield PythonMismatchedPackageName(normalize(pypi_name), pkg=pkg)
diff --git a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
index 3c85ada5..5142f6a8 100644
--- a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
+++ b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json
@@ -1 +1,2 @@
-{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName1", "recommended": "MismatchedPackageName1"}
+{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName0", "recommended": "pythonmismatchedpackagename0"}
+{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName1", "recommended": "mismatchedpackagename1"}
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-11-22 21:35 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-22 21:35 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2024-08-01 19:41 Arthur Zamarin
2023-09-23 15:10 Arthur Zamarin
2023-04-24 16:43 Arthur Zamarin
2023-02-03 13:03 Arthur Zamarin
2023-01-30 19:07 Arthur Zamarin
2023-01-18 5:19 Arthur Zamarin
2023-01-18 5:19 Arthur Zamarin
2023-01-14 20:29 Arthur Zamarin
2023-01-02 20:19 Arthur Zamarin
2022-10-30 18:04 Arthur Zamarin
2022-10-13 17:06 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox