Skip to content

Commit 0337dba

Browse files
committed
Fix pyproject-cache-keys inheritance handling.
1 parent 8661dd8 commit 0337dba

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## 0.23.2
4+
5+
Fix `[[tool.dev-cmd.python]] pyproject-cache-keys` inheritance handling.
6+
37
## 0.23.1
48

59
Fix regression in `when` handling for 1st defined `[[tool.dev-cmd.python]]`.

dev_cmd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright 2024 John Sirois.
22
# Licensed under the Apache License, Version 2.0 (see LICENSE).
33

4-
__version__ = "0.23.1"
4+
__version__ = "0.23.2"

dev_cmd/parse.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def _parse_python(
586586
),
587587
)
588588

589-
cache_key_inputs_pyproject_data = defaults.cache_key_inputs.pyproject_data if defaults else {}
589+
cache_key_inputs_pyproject_data = defaults.cache_key_inputs.pyproject_data if defaults else None
590590
pyproject_cache_keys_data = python_config_data.pop("pyproject-cache-keys", None)
591591

592592
cache_key_inputs_paths = set(defaults.cache_key_inputs.paths) if defaults else set()
@@ -672,12 +672,13 @@ def validate_path(path: str) -> str:
672672
cache_key_inputs_paths = input_paths
673673

674674
if (
675-
pyproject_cache_keys_data is None and not cache_key_inputs_pyproject_data
676-
) or pyproject_cache_keys_data:
675+
pyproject_cache_keys_data is None and cache_key_inputs_pyproject_data is None
676+
) or pyproject_cache_keys_data is not None:
677677
cache_key_inputs_paths.discard("pyproject.toml")
678678
input_keys = (
679679
_assert_list_str(
680-
pyproject_cache_keys_data, path="[tool.dev-cmd.python.requirements] `input-keys`"
680+
pyproject_cache_keys_data,
681+
path=f"[tool.dev-cmd] `python[{index}].pyproject-cache-keys]",
681682
)
682683
if pyproject_cache_keys_data is not None
683684
else ["build-system", "project", "project.optional-dependencies"]
@@ -689,14 +690,14 @@ def validate_path(path: str) -> str:
689690
value = value.get(component, None)
690691
if value is None:
691692
raise InvalidModelError(
692-
f"The [tool.dev-cmd.python.requirements] `input-keys` key of {key} could "
693-
f"not be found in pyproject.toml."
693+
f"The [tool.dev-cmd] `python[{index}].pyproject-cache-keys` key of {key} "
694+
f"could not be found in pyproject.toml."
694695
)
695696
input_item_data[key] = value
696697
cache_key_inputs_pyproject_data = input_item_data
697698

698699
cache_key_inputs = CacheKeyInputs(
699-
pyproject_data=cache_key_inputs_pyproject_data,
700+
pyproject_data=cache_key_inputs_pyproject_data or {},
700701
envs=cache_key_inputs_envs,
701702
paths=tuple(sorted(cache_key_inputs_paths)),
702703
)
@@ -747,7 +748,7 @@ def _parse_pythons(
747748
python_config = (
748749
defaults
749750
if index == 0
750-
else _parse_python(0, python_data, pyproject_data, defaults=defaults)
751+
else _parse_python(index, python_data, pyproject_data, defaults=defaults)
751752
)
752753
activated_index = index
753754

0 commit comments

Comments
 (0)