Skip to content

Commit bc30dd1

Browse files
authored
Modular Conversion --fix_and_overwrite on Windows (#36583)
* Modular Conversion --fix_and_overwrite on Windows * -newline on read
1 parent 9e38510 commit bc30dd1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

utils/check_modular_conversion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def process_file(modular_file_path, generated_modeling_content, file_type="model
2323
file_name_suffix = file_type.split("*")[-1] if "*" in file_type else ""
2424
file_path = modular_file_path.replace("modular_", f"{file_name_prefix}_").replace(".py", f"{file_name_suffix}.py")
2525
# Read the actual modeling file
26-
with open(file_path, "r") as modeling_file:
26+
with open(file_path, "r", encoding="utf-8") as modeling_file:
2727
content = modeling_file.read()
2828
output_buffer = StringIO(generated_modeling_content[file_type][0])
2929
output_buffer.seek(0)
@@ -39,7 +39,7 @@ def process_file(modular_file_path, generated_modeling_content, file_type="model
3939
# Check for differences
4040
if diff_list:
4141
if fix_and_overwrite:
42-
with open(file_path, "w") as modeling_file:
42+
with open(file_path, "w", encoding="utf-8", newline="\n") as modeling_file:
4343
modeling_file.write(generated_modeling_content[file_type][0])
4444
console.print(f"[bold blue]Overwritten {file_path} with the generated content.[/bold blue]")
4545
else:

utils/create_dependency_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def topological_sort(dependencies: dict):
3030

3131
# Function to extract class and import info from a file
3232
def extract_classes_and_imports(file_path):
33-
with open(file_path, "r") as file:
33+
with open(file_path, "r", encoding="utf-8") as file:
3434
tree = ast.parse(file.read(), filename=file_path)
3535
imports = set()
3636

0 commit comments

Comments
 (0)