1 |
commit: ac309733f5680c10bf95bf5d7e318e6e4c1d0ee9 |
2 |
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 31 16:44:15 2023 +0000 |
4 |
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 31 16:44:15 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=ac309733 |
7 |
|
8 |
PythonPackageNameCheck: update docs & add tests |
9 |
|
10 |
Follows: 4438566500fdf116ba36c3c407022e89541867d6 |
11 |
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> |
12 |
|
13 |
src/pkgcheck/checks/python.py | 14 +++++++++----- |
14 |
.../PythonMismatchedPackageName/expected.json | 1 + |
15 |
.../PythonMismatchedPackageName0-0.ebuild | 9 +++++++++ |
16 |
.../dev-python/PythonMismatchedPackageName0/metadata.xml | 7 +++++++ |
17 |
.../PythonMismatchedPackageName1-0.ebuild | 9 +++++++++ |
18 |
.../dev-python/PythonMismatchedPackageName1/metadata.xml | 7 +++++++ |
19 |
.../PythonMismatchedPackageName3-0.ebuild | 9 +++++++++ |
20 |
.../dev-python/PythonMismatchedPackageName3/metadata.xml | 8 ++++++++ |
21 |
.../dev-python/python-mismatched-package-name/metadata.xml | 7 +++++++ |
22 |
.../python-mismatched-package-name-0.ebuild | 9 +++++++++ |
23 |
10 files changed, 75 insertions(+), 5 deletions(-) |
24 |
|
25 |
diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py |
26 |
index 6965d2a9..41edac21 100644 |
27 |
--- a/src/pkgcheck/checks/python.py |
28 |
+++ b/src/pkgcheck/checks/python.py |
29 |
@@ -699,7 +699,13 @@ class PythonGHDistfileSuffixCheck(Check): |
30 |
|
31 |
|
32 |
class PythonMismatchedPackageName(results.PackageResult, results.Info): |
33 |
- """Package name does not follow PyPI-based naming policy""" |
34 |
+ """Package name does not follow PyPI-based naming policy. |
35 |
+ |
36 |
+ All packages in ``dev-python/*`` that are published on PyPI, must be named to |
37 |
+ match their respective PyPI names [#]_. |
38 |
+ |
39 |
+ .. [#] https://projects.gentoo.org/python/guide/package-maintenance.html#package-name-policy |
40 |
+ """ |
41 |
|
42 |
def __init__(self, recommended: str, **kwargs): |
43 |
super().__init__(**kwargs) |
44 |
@@ -707,8 +713,7 @@ class PythonMismatchedPackageName(results.PackageResult, results.Info): |
45 |
|
46 |
@property |
47 |
def desc(self) -> str: |
48 |
- return ("package name does not match remote-id, recommended name: " |
49 |
- f"{self.recommended!r}") |
50 |
+ return f"package name does not match remote-id, recommended name: {self.recommended!r}" |
51 |
|
52 |
|
53 |
class PythonPackageNameCheck(Check): |
54 |
@@ -739,5 +744,4 @@ class PythonPackageNameCheck(Check): |
55 |
|
56 |
pypi_name = pypi_remotes[0].name |
57 |
if normalize(pkg.package) != normalize(pypi_name): |
58 |
- yield PythonMismatchedPackageName(pypi_name.replace(".", "-"), |
59 |
- pkg=pkg) |
60 |
+ yield PythonMismatchedPackageName(pypi_name.replace(".", "-"), pkg=pkg) |
61 |
|
62 |
diff --git a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json |
63 |
new file mode 100644 |
64 |
index 00000000..3c85ada5 |
65 |
--- /dev/null |
66 |
+++ b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json |
67 |
@@ -0,0 +1 @@ |
68 |
+{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName1", "recommended": "MismatchedPackageName1"} |
69 |
|
70 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild |
71 |
new file mode 100644 |
72 |
index 00000000..0c3de1e6 |
73 |
--- /dev/null |
74 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/PythonMismatchedPackageName0-0.ebuild |
75 |
@@ -0,0 +1,9 @@ |
76 |
+# Copyright 2022 Gentoo Authors |
77 |
+# Distributed under the terms of the GNU General Public License v2 |
78 |
+ |
79 |
+EAPI=8 |
80 |
+ |
81 |
+DESCRIPTION="Ebuild with matching name with PyPI" |
82 |
+HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
83 |
+LICENSE="BSD" |
84 |
+SLOT="0" |
85 |
|
86 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml |
87 |
new file mode 100644 |
88 |
index 00000000..07ce2e64 |
89 |
--- /dev/null |
90 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName0/metadata.xml |
91 |
@@ -0,0 +1,7 @@ |
92 |
+<?xml version="1.0" encoding="UTF-8"?> |
93 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
94 |
+<pkgmetadata> |
95 |
+ <upstream> |
96 |
+ <remote-id type="pypi">PythonMismatchedPackageName0</remote-id> |
97 |
+ </upstream> |
98 |
+</pkgmetadata> |
99 |
|
100 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild |
101 |
new file mode 100644 |
102 |
index 00000000..450671b5 |
103 |
--- /dev/null |
104 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/PythonMismatchedPackageName1-0.ebuild |
105 |
@@ -0,0 +1,9 @@ |
106 |
+# Copyright 2022 Gentoo Authors |
107 |
+# Distributed under the terms of the GNU General Public License v2 |
108 |
+ |
109 |
+EAPI=8 |
110 |
+ |
111 |
+DESCRIPTION="Ebuild with not matching name with PyPI" |
112 |
+HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
113 |
+LICENSE="BSD" |
114 |
+SLOT="0" |
115 |
|
116 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml |
117 |
new file mode 100644 |
118 |
index 00000000..14221de3 |
119 |
--- /dev/null |
120 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName1/metadata.xml |
121 |
@@ -0,0 +1,7 @@ |
122 |
+<?xml version="1.0" encoding="UTF-8"?> |
123 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
124 |
+<pkgmetadata> |
125 |
+ <upstream> |
126 |
+ <remote-id type="pypi">MismatchedPackageName1</remote-id> |
127 |
+ </upstream> |
128 |
+</pkgmetadata> |
129 |
|
130 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild |
131 |
new file mode 100644 |
132 |
index 00000000..6126af5d |
133 |
--- /dev/null |
134 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/PythonMismatchedPackageName3-0.ebuild |
135 |
@@ -0,0 +1,9 @@ |
136 |
+# Copyright 2022 Gentoo Authors |
137 |
+# Distributed under the terms of the GNU General Public License v2 |
138 |
+ |
139 |
+EAPI=8 |
140 |
+ |
141 |
+DESCRIPTION="Ebuild with multiple not matching name with PyPI" |
142 |
+HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
143 |
+LICENSE="BSD" |
144 |
+SLOT="0" |
145 |
|
146 |
diff --git a/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml |
147 |
new file mode 100644 |
148 |
index 00000000..3601354e |
149 |
--- /dev/null |
150 |
+++ b/testdata/repos/python/dev-python/PythonMismatchedPackageName3/metadata.xml |
151 |
@@ -0,0 +1,8 @@ |
152 |
+<?xml version="1.0" encoding="UTF-8"?> |
153 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
154 |
+<pkgmetadata> |
155 |
+ <upstream> |
156 |
+ <remote-id type="pypi">MismatchedPackageName3</remote-id> |
157 |
+ <remote-id type="pypi">PackageName3</remote-id> |
158 |
+ </upstream> |
159 |
+</pkgmetadata> |
160 |
|
161 |
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 |
162 |
new file mode 100644 |
163 |
index 00000000..10320a70 |
164 |
--- /dev/null |
165 |
+++ b/testdata/repos/python/dev-python/python-mismatched-package-name/metadata.xml |
166 |
@@ -0,0 +1,7 @@ |
167 |
+<?xml version="1.0" encoding="UTF-8"?> |
168 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
169 |
+<pkgmetadata> |
170 |
+ <upstream> |
171 |
+ <remote-id type="pypi">python.mismatched.package.name</remote-id> |
172 |
+ </upstream> |
173 |
+</pkgmetadata> |
174 |
|
175 |
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 |
176 |
new file mode 100644 |
177 |
index 00000000..0c3de1e6 |
178 |
--- /dev/null |
179 |
+++ b/testdata/repos/python/dev-python/python-mismatched-package-name/python-mismatched-package-name-0.ebuild |
180 |
@@ -0,0 +1,9 @@ |
181 |
+# Copyright 2022 Gentoo Authors |
182 |
+# Distributed under the terms of the GNU General Public License v2 |
183 |
+ |
184 |
+EAPI=8 |
185 |
+ |
186 |
+DESCRIPTION="Ebuild with matching name with PyPI" |
187 |
+HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
188 |
+LICENSE="BSD" |
189 |
+SLOT="0" |