Skip to content

Commit c613b99

Browse files
author
Terry Zhao
committed
regenerate with fix
1 parent 63e8fde commit c613b99

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

test-proj/src/test_proj/export_types.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,20 @@ def post_process_typescript_declarations(schema_dir: Path) -> None:
6565
index_signature_unknown_pattern = re.compile(r"\[k:\s*string\]:\s*unknown;?")
6666
index_signature_any_pattern = re.compile(r"\[k:\s*string\]:\s*any;?")
6767
import_statement = "import type { JSONObject } from '@llamaindex/ui';\n"
68-
import_regex = re.compile(r"import\s+type\s+\{\s*JSONObject\s*\}\s+from\s+'@llamaindex/ui';")
68+
import_regex = re.compile(
69+
r"import\s+type\s+\{\s*JSONObject\s*\}\s+from\s+'@llamaindex/ui';"
70+
)
6971

7072
for dts_path in schema_dir.glob("*.d.ts"):
7173
content = dts_path.read_text(encoding="utf-8")
7274

7375
# Replace index signature value types
74-
new_content = index_signature_unknown_pattern.sub("[k: string]: JSONObject;", content)
75-
new_content = index_signature_any_pattern.sub("[k: string]: JSONObject;", new_content)
76+
new_content = index_signature_unknown_pattern.sub(
77+
"[k: string]: JSONObject;", content
78+
)
79+
new_content = index_signature_any_pattern.sub(
80+
"[k: string]: JSONObject;", new_content
81+
)
7682

7783
# Insert import if JSONObject is used and import not present
7884
if "JSONObject" in new_content and not import_regex.search(new_content):
@@ -82,8 +88,14 @@ def post_process_typescript_declarations(schema_dir: Path) -> None:
8288
if banner_end != -1:
8389
# Move to the next newline after banner
8490
next_newline = new_content.find("\n", banner_end + 2)
85-
insertion_index = next_newline + 1 if next_newline != -1 else banner_end + 2
86-
new_content = new_content[:insertion_index] + import_statement + new_content[insertion_index:]
91+
insertion_index = (
92+
next_newline + 1 if next_newline != -1 else banner_end + 2
93+
)
94+
new_content = (
95+
new_content[:insertion_index]
96+
+ import_statement
97+
+ new_content[insertion_index:]
98+
)
8799

88100
if new_content != content:
89101
dts_path.write_text(new_content, encoding="utf-8")

0 commit comments

Comments
 (0)