From 85ca00b5741146311ec137743ba72cfe802be7c4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Sat, 19 Apr 2025 11:35:13 +0500 Subject: [PATCH 1/2] Conformance - fix saving toml results file in non-unicode Noticed that pyright is giving unicode output that on Windows is leading to issues generating reports later. Saving this output explicitly as unicode resolves the issue. ```python Generating summary report Traceback (most recent call last): File "\typing\conformance\src\main.py", line 260, in main() File "\typing\conformance\src\main.py", line 256, in main generate_summary(root_dir) File "\typing\conformance\src\reporting.py", line 19, in generate_summary summary = template.replace("{{summary}}", generate_summary_html(root_dir)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\typing\conformance\src\reporting.py", line 87, in generate_summary_html results = tomli.load(f) ^^^^^^^^^^^^^ File "src\tomli\_parser.py", line 134, in load UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 110: invalid start byte ``` --- conformance/src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/src/main.py b/conformance/src/main.py index 3f4b1297..0c8a3b5a 100644 --- a/conformance/src/main.py +++ b/conformance/src/main.py @@ -197,7 +197,7 @@ def update_output_for_test( notes = "\n" + notes existing_results["notes"] = tomlkit.string(notes, multiline=True) results_file.parent.mkdir(parents=True, exist_ok=True) - with open(results_file, "w") as f: + with open(results_file, "w", encoding="utf-8") as f: tomlkit.dump(existing_results, f) From dfad1b7168971fb8c2197bbdd359d294e01fa452 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Sat, 19 Apr 2025 13:17:08 +0500 Subject: [PATCH 2/2] Conformance - skip Pyre on Windows as it's not supported --- conformance/README.md | 3 ++- conformance/requirements.txt | 2 +- conformance/src/type_checker.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conformance/README.md b/conformance/README.md index a0a82135..7abe0c43 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -60,7 +60,8 @@ To run the conformance test suite: * Switch to the `conformance` subdirectory and install all dependencies (`pip install -r requirements.txt`). * Switch to the `src` subdirectory and run `python main.py`. -Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker. +Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker. +Currently, the only unsupported type checker is Pyre on Windows. ## Reporting Conformance Results diff --git a/conformance/requirements.txt b/conformance/requirements.txt index d4c4d5a8..f4dafc20 100644 --- a/conformance/requirements.txt +++ b/conformance/requirements.txt @@ -4,5 +4,5 @@ tqdm pyright mypy pip -pyre-check +pyre-check; platform_system != "Windows" pytype diff --git a/conformance/src/type_checker.py b/conformance/src/type_checker.py index d5ee0dfa..05f4485a 100644 --- a/conformance/src/type_checker.py +++ b/conformance/src/type_checker.py @@ -387,6 +387,6 @@ def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: TYPE_CHECKERS: Sequence[TypeChecker] = ( MypyTypeChecker(), PyrightTypeChecker(), - PyreTypeChecker(), + *([] if os.name == "nt" else [PyreTypeChecker()]), PytypeTypeChecker(), )