Skip to content

Commit 8e17796

Browse files
split out normalizing version keywork normalization
1 parent e8e5c45 commit 8e17796

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/setuptools_scm/_integration/setuptools.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@ def _log_hookstart(hook: str, dist: setuptools.Distribution) -> None:
6262
log.debug("%s %s %s %r", hook, id(dist), id(dist.metadata), vars(dist.metadata))
6363

6464

65+
def get_keyword_overrides(
66+
value: bool | dict[str, Any] | Callable[[], dict[str, Any]],
67+
) -> dict[str, Any]:
68+
"""normalize the version keyword input"""
69+
if value is True:
70+
return {}
71+
elif callable(value):
72+
return value()
73+
else:
74+
assert isinstance(value, dict), "version_keyword expects a dict or True"
75+
return value
76+
77+
6578
def version_keyword(
6679
dist: setuptools.Distribution,
6780
keyword: str,
6881
value: bool | dict[str, Any] | Callable[[], dict[str, Any]],
6982
) -> None:
83+
_log_hookstart("version_keyword", dist)
84+
7085
# Parse overrides (integration point responsibility)
71-
overrides: dict[str, Any]
72-
if value is True:
73-
overrides = {}
74-
elif callable(value):
75-
overrides = value()
76-
else:
77-
assert isinstance(value, dict), "version_keyword expects a dict or True"
78-
overrides = value
86+
overrides = get_keyword_overrides(value)
7987

8088
assert "dist_name" not in overrides, (
8189
"dist_name may not be specified in the setup keyword "
@@ -84,7 +92,6 @@ def version_keyword(
8492
dist_name: str | None = _dist_name_from_legacy(dist)
8593

8694
was_set_by_infer = getattr(dist, "_setuptools_scm_version_set_by_infer", False)
87-
_log_hookstart("version_keyword", dist)
8895

8996
# Get pyproject data
9097
try:
@@ -139,7 +146,7 @@ def infer_version(dist: setuptools.Distribution) -> None:
139146
try:
140147
pyproject_data = read_pyproject(Path("pyproject.toml"), missing_section_ok=True)
141148
except FileNotFoundError:
142-
log.debug("pyproject.toml not found")
149+
log.debug("pyproject.toml not found, skipping infer_version")
143150
return
144151
except (LookupError, ValueError) as e:
145152
log.debug("Configuration issue in pyproject.toml: %s", e)

0 commit comments

Comments
 (0)