From 364c0579f76e06f9001fe2369f7794a54c6506bc Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:37:38 +0100 Subject: [PATCH] ENH: standardize PyPI URLs --- pyproject.toml | 4 ++- .../check_dev_files/pyproject.py | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8d7ebd55..10f9d56d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,8 +53,10 @@ set-nb-display-name = "compwa_policy.set_nb_display_name:main" strip-nb-whitespace = "compwa_policy.strip_nb_whitespace:main" [project.urls] +Changelog = "https://github.com/ComPWA/policy/releases" +Documentation = "https://compwa.github.io/policy" +Issues = "https://github.com/ComPWA/policy/issues" Source = "https://github.com/ComPWA/policy" -Tracker = "https://github.com/ComPWA/policy/issues" [dependency-groups] dev = [ diff --git a/src/compwa_policy/check_dev_files/pyproject.py b/src/compwa_policy/check_dev_files/pyproject.py index 5c66a144..0796a7e1 100644 --- a/src/compwa_policy/check_dev_files/pyproject.py +++ b/src/compwa_policy/check_dev_files/pyproject.py @@ -22,12 +22,46 @@ def main(excluded_python_versions: set[PythonVersion]) -> None: if not CONFIG_PATH.pyproject.exists(): return with ModifiablePyproject.load() as pyproject: + _update_pypi_link_names(pyproject) _convert_to_dependency_groups(pyproject) _rename_sty_to_style(pyproject) _update_requires_python(pyproject) _update_python_version_classifiers(pyproject, excluded_python_versions) +def _update_pypi_link_names(pyproject: ModifiablePyproject) -> None: + project_urls = pyproject.get_table("project.urls", fallback={}) + if not project_urls: + return + if any(name[0].islower() for name in project_urls): + pyproject.get_table("project")["urls"] = { + k.capitalize(): v for k, v in project_urls.items() + } + pyproject.changelog.append("Capitalized PyPI link names") + renames = { + # https://packaging.python.org/specifications/well-known-project-urls/#well-known-labels + "Changes": "Changelog", + "History": "Changelog", + "Whatsnew": "Changelog", # cspell:ignore Whatsnew + "Docs": "Documentation", + "Donate": "Funding", + "Donation": "Funding", + "Sponsor": "Funding", + "Bugs": "Issues", + "Bugtracker": "Issues", # cspell:ignore Bugtracker + "Issue": "Issues", + "Issuetracker": "Issues", # cspell:ignore Issuetracker + "Tracker": "Issues", + "Github": "Source", + "Repository": "Source", + "Sourcecode": "Source", + } + for old_name, new_name in renames.items(): + if old_name in project_urls: + project_urls[new_name] = project_urls.pop(old_name) + pyproject.changelog.append(f'Renamed "{old_name}" link to "{new_name}"') + + def _convert_to_dependency_groups(pyproject: ModifiablePyproject) -> None: table_key = "project.optional-dependencies" if not pyproject.has_table(table_key):