Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cookiecutter/apply_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
1 change: 1 addition & 0 deletions cookiecutter/ci/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down
24 changes: 23 additions & 1 deletion cookiecutter/pulp_filter_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.")

Expand Down
Loading