From 26a4ed190111d2f36949747cd7680c0b33270884 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 8 Nov 2026 00:46:11 +0000 Subject: [PATCH] Update cookiecutter --- cookiecutter/apply_templates.py | 5 +++ cookiecutter/ci/cookiecutter.json | 1 + .../pyproject.toml.update | 31 +++---------------- cookiecutter/pulp_filter_extension.py | 24 +++++++++++++- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/cookiecutter/apply_templates.py b/cookiecutter/apply_templates.py index 07ea8c2b5..bbd0c1ed2 100755 --- a/cookiecutter/apply_templates.py +++ b/cookiecutter/apply_templates.py @@ -63,6 +63,11 @@ def main(bootstrap: bool, force: bool) -> None: sections.append("ci") with Path(".github/workflows/test.yml").open() as fp: config["test_matrix"] = yaml.safe_load(fp)["jobs"]["test"]["strategy"]["matrix"] + # Take test and dev dependencies from pulp-cli. + pulp_cli_pyproject = tomllib.loads( + (Path(__file__).parent.parent / "pyproject.toml").read_text() + ) + config["dependency_groups"] = pulp_cli_pyproject["dependency-groups"] # Docs if config["docs"]: diff --git a/cookiecutter/ci/cookiecutter.json b/cookiecutter/ci/cookiecutter.json index 4939c48b2..4d282b364 100644 --- a/cookiecutter/ci/cookiecutter.json +++ b/cookiecutter/ci/cookiecutter.json @@ -8,6 +8,7 @@ "binary_dependencies": "", "current_version": "0.0.1.dev", "test_matrix": null, + "dependency_groups": null, "unittests": false, "paralleltests": false, "__app_label_suffix": "{{ cookiecutter.app_label and '-' + cookiecutter.app_label }}", diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update index f00297aad..c35cf8be4 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update @@ -4,34 +4,11 @@ {%- set src_infix = "src/" if cookiecutter.src_layout else "" %} [dependency-groups] # This section is managed by the cookiecutter templates. -dev = [ - {include-group = "lint"}, - "pylsp-mypy>=0.7.0", - "pylsp-rope>=0.1.17,<0.1.18", -] -lint = [ - {include-group = "test"}, - "mypy~=2.4.0", - "ruff~=0.16.0", - "shellcheck-py~=0.11.0.1", - "types-pygments", - "types-pyyaml", - "types-requests", - "types-setuptools", - "types-toml", -] -test = [ - "pygments>=2.19.2", - "pytest>=7.0.0,<9.2", - "pytest-xdist>=3.8.0,<3.9", - "python-gnupg>=0.5.0,<0.6", - "secretstorage>=3.5.0", - "trustme>=1.1.0,<1.3", -] +dev = {{ cookiecutter.dependency_groups.dev | toml_value }} +lint = {{ cookiecutter.dependency_groups.lint | toml_value }} +test = {{ cookiecutter.dependency_groups.test | toml_value}} {%- if cookiecutter.docs %} -docs = [ - "pulp-docs", -] +docs = {{ cookiecutter.dependency_groups.docs | toml_value}} {%- endif %} {%- if cookiecutter.glue or cookiecutter.docs %} diff --git a/cookiecutter/pulp_filter_extension.py b/cookiecutter/pulp_filter_extension.py index 94a0063eb..317d501b7 100644 --- a/cookiecutter/pulp_filter_extension.py +++ b/cookiecutter/pulp_filter_extension.py @@ -15,7 +15,7 @@ def _quote(s: str) -> str: return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"' -def to_toml_value(value: t.Any) -> str: +def to_toml_value(value: t.Any, /, oneline=False) -> str: if isinstance(value, str): return '"' + value + '"' elif value is True: @@ -24,6 +24,28 @@ def to_toml_value(value: t.Any) -> str: return "false" elif isinstance(value, int): return str(value) + elif isinstance(value, list): + if oneline: + prefix = "[" + infix = ", " + postfix = "]" + else: + prefix = "[\n " + infix = ",\n " + postfix = ",\n]" + items = [to_toml_value(v, oneline=True) for v in value] + return prefix + infix.join(items) + postfix + elif isinstance(value, dict): + if oneline: + prefix = "{" + infix = ", " + postfix = "}" + else: + prefix = "{\n " + infix = ",\n " + postfix = ",\n}" + items = [f"{k} = {to_toml_value(v, oneline=True)}" for k, v in value.items()] + return prefix + infix.join(items) + postfix else: raise NotImplementedError("Not an atomic value.")