|
41 | 41 | verify_cognite_client_is_up_to_date, |
42 | 42 | ) |
43 | 43 |
|
44 | | -SYNC_API_TEMPLATE = Path("scripts/sync_client_codegen/sync_api_template.txt").read_text() |
| 44 | +SYNC_API_TEMPLATE = Path("scripts/sync_client_codegen/sync_api_template.txt").read_text(encoding="utf-8") |
45 | 45 |
|
46 | 46 |
|
47 | 47 | def _generate_code_for_single_sync_api( |
@@ -258,7 +258,7 @@ def _compare_normalized_files_and_maybe_update_hash_only(files_to_update: set[Si |
258 | 258 | for f in files_to_update: |
259 | 259 | f.temp_filepath = tmp_dir / f.filepath |
260 | 260 | ensure_parent_dir(f.temp_filepath) |
261 | | - f.temp_filepath.write_text(f.get_new_source) |
| 261 | + f.temp_filepath.write_text(f.get_new_source, encoding="utf-8") |
262 | 262 |
|
263 | 263 | # Before compare, we need to run ruff (large overhead, so we do it once for all files): |
264 | 264 | run_ruff([f.temp_filepath for f in files_to_update], verbose=False) |
@@ -295,7 +295,7 @@ def _compare_normalized_files_and_maybe_update_hash_only(files_to_update: set[Si |
295 | 295 | # Note: DO NOT use normalized_src here, the reason we do all of this is precisely to preserve |
296 | 296 | # e.g. type-ignore comments that would otherwise be lost on regeneration. |
297 | 297 | current_source = get_source_code(write_file) |
298 | | - write_file.write_text(current_source.replace(existing_hash, f.get_new_hash)) |
| 298 | + write_file.write_text(current_source.replace(existing_hash, f.get_new_hash), encoding="utf-8") |
299 | 299 |
|
300 | 300 |
|
301 | 301 | def _report_after_verification( |
@@ -335,7 +335,7 @@ def _report_after_verification( |
335 | 335 | def _write_updated_sync_api_files(files_to_update: set[SingleAPIFile]) -> None: |
336 | 336 | for f in files_to_update: |
337 | 337 | ensure_parent_dir(f.filepath) |
338 | | - f.filepath.write_text(f.get_new_source) |
| 338 | + f.filepath.write_text(f.get_new_source, encoding="utf-8") |
339 | 339 | if f.class_name: |
340 | 340 | print(f"- Generated/updated sync API code for {f.class_name} from '{f.read_filepath}' ✅") |
341 | 341 | else: |
@@ -391,7 +391,7 @@ def _run_files( |
391 | 391 |
|
392 | 392 | if client_has_changed: |
393 | 393 | to_be_linted.append(SYNC_CLIENT_PATH) |
394 | | - SYNC_CLIENT_PATH.write_text(new_client_source_code) |
| 394 | + SYNC_CLIENT_PATH.write_text(new_client_source_code, encoding="utf-8") |
395 | 395 | print(f"- Regenerated (sync) CogniteClient: '{SYNC_CLIENT_PATH}' ✅") |
396 | 396 | elif args.verbose: |
397 | 397 | print(f"- Skipped (sync) CogniteClient, is up to date: '{SYNC_CLIENT_PATH}' ⏭️") |
|
0 commit comments