Skip to content

Commit 4641205

Browse files
Merge branch 'develop' into 4940-add-visibility-argument
2 parents 681ff29 + c263e9f commit 4641205

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

polyapi/generate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,20 +503,20 @@ def add_function_file(
503503
# Read current __init__.py content if it exists
504504
init_content = ""
505505
if os.path.exists(init_path):
506-
with open(init_path, "r") as f:
506+
with open(init_path, "r", encoding='utf-8') as f:
507507
init_content = f.read()
508508

509509
# Prepare new content to append to __init__.py
510510
new_init_content = init_content + f"\n\nfrom . import {func_namespace}\n\n{func_str}"
511511

512512
# Use temporary files for atomic writes
513513
# Write to __init__.py atomically
514-
with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=full_path, suffix=".tmp") as temp_init:
514+
with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=full_path, suffix=".tmp", encoding='utf-8') as temp_init:
515515
temp_init.write(new_init_content)
516516
temp_init_path = temp_init.name
517517

518518
# Write to function file atomically
519-
with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=full_path, suffix=".tmp") as temp_func:
519+
with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=full_path, suffix=".tmp", encoding='utf-8') as temp_func:
520520
temp_func.write(func_type_defs)
521521
temp_func_path = temp_func.name
522522

polyapi/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def init_the_init(full_path: str, code_imports: Optional[str] = None) -> None:
2424
if not os.path.exists(init_path):
2525
if code_imports is None:
2626
code_imports = CODE_IMPORTS
27-
with open(init_path, "w") as f:
27+
with open(init_path, "w", encoding='utf-8') as f:
2828
f.write(code_imports)
2929

3030

@@ -33,7 +33,7 @@ def add_import_to_init(full_path: str, next: str, code_imports: Optional[str] =
3333
init_the_init(full_path, code_imports=code_imports)
3434

3535
init_path = os.path.join(full_path, "__init__.py")
36-
with open(init_path, "a+") as f:
36+
with open(init_path, "a+", encoding='utf-8') as f:
3737
import_stmt = "from . import {}\n".format(next)
3838
f.seek(0)
3939
lines = f.readlines()

0 commit comments

Comments
 (0)