From 7a82b13dff7762f55a6071f745c93e20a829f89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 10 Jan 2026 23:27:01 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Update=20file=20read=20wit?= =?UTF-8?q?h=20explicit=20encoding=20because=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docs.py | 2 +- scripts/notify_translations.py | 2 +- .../test_code_blocks_lines_number_mismatch.py | 16 ++++++++-------- .../test_code_blocks/test_code_blocks_mermaid.py | 8 ++++---- .../test_code_blocks_number_mismatch.py | 12 ++++++++---- .../test_code_blocks_wrong_lang_code.py | 12 ++++++------ .../test_code_includes/test_number_mismatch.py | 12 ++++++++---- .../test_complex_doc/test_compex_doc.py | 4 ++-- .../test_header_level_mismatch.py | 8 ++++---- .../test_header_number_mismatch.py | 12 ++++++++---- .../test_html_links_number_mismatch.py | 12 ++++++++---- .../test_mkd_links_number_mismatch.py | 12 ++++++++---- 12 files changed, 66 insertions(+), 46 deletions(-) diff --git a/scripts/docs.py b/scripts/docs.py index fbde1eca4..84cf01c72 100644 --- a/scripts/docs.py +++ b/scripts/docs.py @@ -239,7 +239,7 @@ def generate_readme() -> None: Generate README.md content from main index.md """ readme_path = Path("README.md") - old_content = readme_path.read_text() + old_content = readme_path.read_text("utf-8") new_content = generate_readme_content() if new_content != old_content: print("README.md outdated from the latest index.md") diff --git a/scripts/notify_translations.py b/scripts/notify_translations.py index 2ca740a60..74cdf0dff 100644 --- a/scripts/notify_translations.py +++ b/scripts/notify_translations.py @@ -316,7 +316,7 @@ def main() -> None: raise RuntimeError( f"No github event file available at: {settings.github_event_path}" ) - contents = settings.github_event_path.read_text() + contents = settings.github_event_path.read_text("utf-8") github_event = PartialGitHubEvent.model_validate_json(contents) logging.info(f"Using GitHub event: {github_event}") number = ( diff --git a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py index 906c8a560..9cdbe8323 100644 --- a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py @@ -22,10 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path( - f"{data_path}/translated_doc_lines_number_gt.md" - ).read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_lines_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -46,10 +46,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) # assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path( - f"{data_path}/translated_doc_lines_number_lt.md" - ).read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_lines_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py index 75c589fb5..8b80c70f3 100644 --- a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py +++ b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py @@ -22,10 +22,10 @@ def test_translated(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 0, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") expected_content = Path( f"{data_path}/translated_doc_mermaid_translated.md" - ).read_text() + ).read_text("utf-8") assert fixed_content == expected_content # Translated doc remains unchanged assert ( @@ -50,10 +50,10 @@ def test_not_translated(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 0, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") expected_content = Path( f"{data_path}/translated_doc_mermaid_not_translated.md" - ).read_text() + ).read_text("utf-8") assert fixed_content == expected_content # Translated doc remains unchanged assert ("Skipping mermaid code block replacement") not in result.output diff --git a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py index b05dac900..ad5767c1c 100644 --- a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py @@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) # assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py index 6c2b18c89..85d73e3b4 100644 --- a/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py +++ b/scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py @@ -22,10 +22,10 @@ def test_wrong_lang_code_1(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path( - f"{data_path}/translated_doc_wrong_lang_code.md" - ).read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_wrong_lang_code.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -46,10 +46,10 @@ def test_wrong_lang_code_2(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") expected_content = Path( f"{data_path}/translated_doc_wrong_lang_code_2.md" - ).read_text() + ).read_text("utf-8") assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py b/scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py index 5e3eee51a..1020b890c 100644 --- a/scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py @@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py b/scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py index 86cc4d5eb..cc7bcadda 100644 --- a/scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py +++ b/scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py @@ -22,8 +22,8 @@ def test_fix(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 0, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = (data_path / "translated_doc_expected.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = (data_path / "translated_doc_expected.md").read_text("utf-8") assert fixed_content == expected_content assert "Fixing multiline code blocks in" in result.output diff --git a/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py b/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py index 9fe2f7ba7..99d27db95 100644 --- a/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py @@ -22,10 +22,10 @@ def test_level_mismatch_1(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") expected_content = Path( f"{data_path}/translated_doc_level_mismatch_1.md" - ).read_text() + ).read_text("utf-8") assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -47,10 +47,10 @@ def test_level_mismatch_2(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") expected_content = Path( f"{data_path}/translated_doc_level_mismatch_2.md" - ).read_text() + ).read_text("utf-8") assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py b/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py index c0e78d030..c4d034617 100644 --- a/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py @@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1 - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py b/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py index 271e5d205..11dcea154 100644 --- a/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py @@ -20,8 +20,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -43,8 +45,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) # assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output diff --git a/scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py b/scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py index 0f4952f35..c72e01254 100644 --- a/scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py +++ b/scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py @@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): ) assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output @@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): ) # assert result.exit_code == 1, result.output - fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() - expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() + fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8") + expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text( + "utf-8" + ) assert fixed_content == expected_content # Translated doc remains unchanged assert "Error processing docs/lang/docs/doc.md" in result.output