Skip to content

Commit 0a629af

Browse files
committed
Use cast for repaired_json instead of isinstance
1 parent 84ac45a commit 0a629af

File tree

3 files changed

+38
-143
lines changed

3 files changed

+38
-143
lines changed

examples/build_graph/simple_kg_builder_from_pdf_ollama.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

poetry.lock

Lines changed: 36 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j_graphrag/experimental/components/entity_relation_extractor.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import json
2121
import logging
2222
from datetime import datetime
23-
from typing import Any, List, Optional, Union
23+
from typing import Any, List, Optional, Union, cast
2424

2525
import json_repair
2626

@@ -104,11 +104,7 @@ def balance_curly_braces(json_string: str) -> str:
104104

105105
def fix_invalid_json(raw_json: str) -> str:
106106
repaired_json = json_repair.repair_json(raw_json)
107-
108-
if isinstance(repaired_json, str):
109-
repaired_json = repaired_json.strip()
110-
else:
111-
repaired_json = ""
107+
repaired_json = cast(str, repaired_json).strip()
112108

113109
if repaired_json == '""':
114110
raise InvalidJSONError("JSON repair resulted in an empty or invalid JSON.")

0 commit comments

Comments
 (0)