Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/convert_library_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def extract_translations_from_metadata(meta_dict, prefix):

# --- Sheet parsing ------------------------------------------------------------


def parse_key_value_sheet(sheet):
result = {}
for row in sheet.iter_rows(min_row=1, max_col=2, values_only=True):
Expand Down Expand Up @@ -992,6 +991,10 @@ def create_library(
node["translations"] = translations
if node.get("urn") in all_urns:
raise ValueError(f"urn already used: {node.get('urn')}")

if node.get("assessable", False) is False and node.get("annotation", ""):
raise ValueError(f"Requirement(with name={repr(node.get("name"))}) can't have a non-empty 'annotation' because it is not an assessable requirement.")
Comment on lines +995 to +996
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix syntax error: nested quotes in f-string.

The f-string on line 996 contains unescaped double quotes inside node.get("name"), which will cause a syntax error.

Apply this diff to fix the syntax error:

-                    if node.get("assessable", False) is False and node.get("annotation", ""):
-                        raise ValueError(f"Requirement(with name={repr(node.get("name"))}) can't have a non-empty 'annotation' because it is not an assessable requirement.")
+                    if node.get("assessable", False) is False and node.get("annotation", ""):
+                        raise ValueError(f"Requirement(with name={repr(node.get('name'))}) can't have a non-empty 'annotation' because it is not an assessable requirement.")

Optional improvement: Consider enhancing the error message to include the URN for easier debugging:

raise ValueError(f"Requirement '{node.get('urn')}' (name={repr(node.get('name'))}) cannot have an annotation because it is not assessable.")
🤖 Prompt for AI Agents
In tools/convert_library_v2.py around lines 995 to 996 the f-string uses nested
double quotes causing a syntax error; replace the inner double quotes with
single quotes (or escape them) so the f-string is valid, and update the message
to be clearer by including the URN: raise a ValueError that references
node.get('urn') and node.get('name') using single quotes inside the f-string
(e.g. "Requirement '{node.get('urn')}' (name={repr(node.get('name'))}) cannot
have an annotation because it is not assessable.").


all_urns.add(node.get("urn"))
requirement_nodes.append(node)

Expand Down
Loading