@@ -115,13 +115,9 @@ def from_frontmatter(
115115
116116 mode_count = sum ([has_trigger , has_set , has_pair ])
117117 if mode_count == 0 :
118- raise PolicyParseError (
119- f"Policy '{ name } ' must have 'trigger', 'set', or 'pair'"
120- )
118+ raise PolicyParseError (f"Policy '{ name } ' must have 'trigger', 'set', or 'pair'" )
121119 if mode_count > 1 :
122- raise PolicyParseError (
123- f"Policy '{ name } ' has multiple detection modes - use only one"
124- )
120+ raise PolicyParseError (f"Policy '{ name } ' has multiple detection modes - use only one" )
125121
126122 # Parse based on detection mode
127123 detection_mode : DetectionMode
@@ -141,9 +137,7 @@ def from_frontmatter(
141137 detection_mode = DetectionMode .SET
142138 set_patterns = list (frontmatter ["set" ])
143139 if len (set_patterns ) < 2 :
144- raise PolicyParseError (
145- f"Policy '{ name } ' set requires at least 2 patterns"
146- )
140+ raise PolicyParseError (f"Policy '{ name } ' set requires at least 2 patterns" )
147141
148142 elif has_pair :
149143 detection_mode = DetectionMode .PAIR
@@ -170,9 +164,7 @@ def from_frontmatter(
170164 action_type = ActionType .PROMPT
171165 # Markdown body is the instructions
172166 if not markdown_body .strip ():
173- raise PolicyParseError (
174- f"Policy '{ name } ' with prompt action requires markdown body"
175- )
167+ raise PolicyParseError (f"Policy '{ name } ' with prompt action requires markdown body" )
176168
177169 # Get compare_to
178170 compare_to = frontmatter .get ("compare_to" , DEFAULT_COMPARE_TO )
@@ -230,9 +222,7 @@ def parse_frontmatter_file(filepath: Path) -> tuple[dict[str, Any], str]:
230222 try :
231223 frontmatter = yaml .safe_load (frontmatter_str )
232224 except yaml .YAMLError as e :
233- raise PolicyParseError (
234- f"Invalid YAML frontmatter in '{ filepath .name } ': { e } "
235- ) from e
225+ raise PolicyParseError (f"Invalid YAML frontmatter in '{ filepath .name } ': { e } " ) from e
236226
237227 if frontmatter is None :
238228 frontmatter = {}
@@ -270,9 +260,7 @@ def parse_policy_file_v2(filepath: Path) -> Policy:
270260 try :
271261 validate_against_schema (frontmatter , POLICY_FRONTMATTER_SCHEMA )
272262 except ValidationError as e :
273- raise PolicyParseError (
274- f"Policy '{ filepath .name } ' validation failed: { e } "
275- ) from e
263+ raise PolicyParseError (f"Policy '{ filepath .name } ' validation failed: { e } " ) from e
276264
277265 # Create Policy object
278266 filename = filepath .stem # filename without .md extension
0 commit comments