Skip to content

Commit ccba7f9

Browse files
committed
running new pre-commit
1 parent d14fb10 commit ccba7f9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

scripts/fix_pydantic.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
""" Using ast transformer to fix some issues with automatic pydantic generation"""
1+
""" Using ast transformer to fix issues with automatic pydantic generation"""
22

3-
import sys
43
import ast
4+
import sys
5+
56
import astor
67

78

@@ -20,7 +21,7 @@ def visit_Expr(self, node):
2021
if isinstance(node.value, ast.Call):
2122
# Check if the call expression is an attribute (method call)
2223
if isinstance(node.value.func, ast.Attribute):
23-
# Check if the method call matches the specified class and method name
24+
# Check if the method call matches the specified class
2425
if (
2526
isinstance(node.value.func.value, ast.Name)
2627
and node.value.func.value.id == self.class_name
@@ -79,7 +80,9 @@ def edit_pydantic(input_file, output_file):
7980
transformer_class = ClassRemover(class_name="LangString")
8081
tree_modclass = transformer_class.visit(tree)
8182

82-
transformer_tp = TypeReplacer(old_type="LangString", new_type="Dict[str, str]")
83+
transformer_tp = TypeReplacer(
84+
old_type="LangString", new_type="Dict[str, str]"
85+
)
8386
tree_modclass_modtype = transformer_tp.visit(tree_modclass)
8487

8588
with open(output_file, "w") as file:
@@ -93,6 +96,7 @@ def edit_pydantic(input_file, output_file):
9396
else:
9497
output_file = sys.argv[2]
9598
print(
96-
f"Fixing automatically generated pydantic file {input_file} and saving to {output_file}"
99+
f"Fixing automatically generated pydantic file {input_file} "
100+
f"and saving to {output_file}"
97101
)
98102
edit_pydantic(input_file, output_file)

0 commit comments

Comments
 (0)