Skip to content

Commit a544e35

Browse files
committed
update
1 parent 9337686 commit a544e35

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

sphinx_needs/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class NeedsInfoType(TypedDict):
462462

463463
# constraints information
464464
# set in process_need_nodes (-> process_constraints) transform
465-
constraints_results: dict[str, dict[str, bool]]
465+
constraints_results: Mapping[str, dict[str, bool]]
466466
"""Mapping of constraint name, to check name, to result."""
467467
constraints_error: None | str
468468
"""An error message set if any constraint failed, and `error_message` field is set in config."""

sphinx_needs/need_constraints.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def process_constraints(needs: NeedsMutable, config: NeedsSphinxConfig) -> None:
2525

2626
for need in needs.values():
2727
need_id = need["id"]
28-
constraints = need["constraints"]
2928

30-
for constraint in constraints:
29+
for constraint in need["constraints_results"]:
3130
try:
3231
executable_constraints = config_constraints[constraint]
3332
except KeyError:
@@ -43,9 +42,7 @@ def process_constraints(needs: NeedsMutable, config: NeedsSphinxConfig) -> None:
4342
# compile constraint and check if need fulfils it
4443
constraint_passed = filter_single_need(need, config, cmd)
4544

46-
need["constraints_results"].setdefault(constraint, {})[name] = (
47-
constraint_passed
48-
)
45+
need["constraints_results"][constraint][name] = constraint_passed
4946
if not constraint_passed:
5047
if "error_message" in executable_constraints:
5148
msg = str(executable_constraints["error_message"])

tests/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_consistent():
6767
elif type_str == "dict[str, str]":
6868
assert schema["type"] == "object", field
6969
assert schema["additionalProperties"]["type"] == "string", field
70-
elif type_str.startswith("dict["):
70+
elif type_str.startswith("dict[") or type_str.startswith("Mapping["):
7171
assert schema["type"] == "object", field
7272
else:
7373
raise ValueError(f"Unknown type: {type_str!r} for {field!r}")

0 commit comments

Comments
 (0)