Skip to content

Commit 74e14d3

Browse files
committed
style: Apply ruff format to 6 files
1 parent 939c828 commit 74e14d3

6 files changed

Lines changed: 65 additions & 24 deletions

File tree

src/ctrlmap/llm/structured_output.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def select_best_rationale(
5353
),
5454
)
5555

56+
5657
_MAX_RETRIES = 2
5758

5859

src/ctrlmap/models/oscal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def parse_oscal_catalog(path: Path) -> list[SecurityControl]:
4646
for group in catalog.get("groups", []):
4747
family = group.get("title", "")
4848
_extract_controls(
49-
group.get("controls", []), controls, framework,
49+
group.get("controls", []),
50+
controls,
51+
framework,
5052
requirement_family=family,
5153
)
5254

@@ -89,7 +91,9 @@ def _extract_controls(
8991
# Recurse into control enhancements (nested controls)
9092
for enhancement in ctrl.get("controls", []):
9193
_extract_controls(
92-
[enhancement], output, framework,
94+
[enhancement],
95+
output,
96+
framework,
9397
requirement_family=requirement_family,
9498
)
9599

src/ctrlmap/parse/chunker.py

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,62 @@ def _merge_short_chunks(chunks: list[str], *, min_length: int = 50) -> list[str]
384384
# Trailing words that signal a chunk was cut mid-clause.
385385
# When a chunk ends with one of these, the next chunk continues the
386386
# sentence regardless of capitalisation.
387-
_TRAILING_WORDS = frozenset({
388-
# prepositions / particles
389-
"of", "for", "in", "to", "with", "from", "by", "at", "on", "into",
390-
"about", "between", "through", "within", "without", "including",
391-
# articles / determiners
392-
"the", "a", "an", "all", "any", "each", "every", "this", "that",
393-
# conjunctions
394-
"and", "or", "nor", "but",
395-
# auxiliary / modal verbs
396-
"be", "is", "are", "was", "were", "been", "being",
397-
"must", "shall", "should", "will", "would", "can", "could", "may",
398-
# common mid-clause endings
399-
"not", "also", "than",
400-
})
387+
_TRAILING_WORDS = frozenset(
388+
{
389+
# prepositions / particles
390+
"of",
391+
"for",
392+
"in",
393+
"to",
394+
"with",
395+
"from",
396+
"by",
397+
"at",
398+
"on",
399+
"into",
400+
"about",
401+
"between",
402+
"through",
403+
"within",
404+
"without",
405+
"including",
406+
# articles / determiners
407+
"the",
408+
"a",
409+
"an",
410+
"all",
411+
"any",
412+
"each",
413+
"every",
414+
"this",
415+
"that",
416+
# conjunctions
417+
"and",
418+
"or",
419+
"nor",
420+
"but",
421+
# auxiliary / modal verbs
422+
"be",
423+
"is",
424+
"are",
425+
"was",
426+
"were",
427+
"been",
428+
"being",
429+
"must",
430+
"shall",
431+
"should",
432+
"will",
433+
"would",
434+
"can",
435+
"could",
436+
"may",
437+
# common mid-clause endings
438+
"not",
439+
"also",
440+
"than",
441+
}
442+
)
401443

402444

403445
def _ends_mid_clause(text: str) -> bool:

tests/unit/test_chunker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,3 @@ def test_overlap_zero_produces_no_overlap(self) -> None:
445445
# Check for duplicates
446446
unique = set(all_sentences_flat)
447447
assert len(unique) == len(all_sentences_flat), "overlap=0 should produce no duplicates"
448-

tests/unit/test_mapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,3 @@ def test_expand_query_noop_for_specific_terms(self) -> None:
205205
expanded = _expand_query(original)
206206
# Should still contain the original text
207207
assert "Account Management" in expanded
208-

tests/unit/test_meta_requirements.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ def test_meta_with_direct_evidence_preserved_when_correct(self) -> None:
470470
framework="PCI-DSS",
471471
title="CISO responsibility formally assigned",
472472
description=(
473-
"Responsibility for information security"
474-
" is formally assigned to a CISO."
473+
"Responsibility for information security is formally assigned to a CISO."
475474
),
476475
),
477476
supporting_chunks=[
@@ -608,8 +607,7 @@ def test_meta_overridden_noncompliant_when_siblings_have_gaps(self) -> None:
608607
# Should be non-compliant — sibling 8.2.5 has a gap
609608
assert isinstance(r824.rationale, MappingRationale)
610609
assert not r824.rationale.is_compliant, (
611-
f"Expected 8.2.4 to be non-compliant (sibling gap), "
612-
f"but got {r824.rationale}"
610+
f"Expected 8.2.4 to be non-compliant (sibling gap), but got {r824.rationale}"
613611
)
614612

615613

@@ -665,5 +663,3 @@ def test_select_best_rationale_empty_list_returns_none(self) -> None:
665663
from ctrlmap.llm.structured_output import select_best_rationale
666664

667665
assert select_best_rationale([]) is None
668-
669-

0 commit comments

Comments
 (0)