Skip to content

Commit 22f830d

Browse files
committed
style: format function parameters for better readability in schema functions
1 parent 04c9307 commit 22f830d

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/extensions/score_metamodel/sn_schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ def add_network_entry(field: str, target_types: list[str]) -> None:
266266
return type_schema
267267

268268

269-
def get_field_pattern_schema(field: str, pattern: str, is_optional: bool = False) -> dict[str, Any]:
269+
def get_field_pattern_schema(
270+
field: str, pattern: str, is_optional: bool = False
271+
) -> dict[str, Any]:
270272
"""Return the appropriate JSON schema for a field's regex pattern.
271273
272274
Array-valued fields (like ``tags``) get an array-of-strings schema;

src/extensions/score_metamodel/tests/test_sn_schemas.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ def test_unknown_field_returns_string_schema(self) -> None:
101101
assert result["type"] == "string"
102102

103103
def test_optional_scalar_field_allows_empty_string(self) -> None:
104-
result = get_field_pattern_schema("mitigation_issue", "^https://github.com/.*$", is_optional=True)
104+
result = get_field_pattern_schema(
105+
"mitigation_issue", "^https://github.com/.*$", is_optional=True
106+
)
105107
assert result == {"type": "string", "pattern": "^$|^https://github.com/.*$"}
106108

107109
def test_mandatory_scalar_field_does_not_allow_empty_string(self) -> None:
108-
result = get_field_pattern_schema("status", "^(valid|invalid)$", is_optional=False)
110+
result = get_field_pattern_schema(
111+
"status", "^(valid|invalid)$", is_optional=False
112+
)
109113
assert result == {"type": "string", "pattern": "^(valid|invalid)$"}
110114
# Should not have alternation with empty string
111115
assert "^$|" not in result.get("pattern", "")
@@ -183,7 +187,10 @@ def test_optional_fields_not_required(self) -> None:
183187
assert "comment" not in result["required"]
184188
assert "comment" in result["properties"]
185189
# Optional fields should allow empty strings via pattern alternation
186-
assert result["properties"]["comment"] == {"type": "string", "pattern": "^$|^.*$"}
190+
assert result["properties"]["comment"] == {
191+
"type": "string",
192+
"pattern": "^$|^.*$",
193+
}
187194

188195
def test_ignored_fields_excluded(self) -> None:
189196
mandatory = {field: "^.*$" for field in IGNORE_FIELDS}

0 commit comments

Comments
 (0)