From 3a81fe51cd7f14e0d82ba32952b827182e3d14c0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 3 Aug 2024 14:57:47 +0300 Subject: [PATCH] Try explicit encoding and suffix --- tests/mypy_test.py | 2 +- tests/stubtest_stdlib.py | 2 +- tests/stubtest_third_party.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 7414c3210b15..adb99a63d497 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -212,7 +212,7 @@ def run_mypy( env_vars = dict(os.environ) if mypypath is not None: env_vars["MYPYPATH"] = mypypath - with tempfile.NamedTemporaryFile("w+") as temp: + with tempfile.NamedTemporaryFile("w+", encoding="utf8", suffix=".ini") as temp: temp.write("[mypy]\n") for dist_conf in configurations: temp.write(f"[mypy-{dist_conf.module_name}]\n") diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py index 28ec3776062c..d6dbb72c90ae 100755 --- a/tests/stubtest_stdlib.py +++ b/tests/stubtest_stdlib.py @@ -22,7 +22,7 @@ def run_stubtest(typeshed_dir: Path) -> int: # This is fine because we don't care about distutils and allowlist all errors from it # https://github.com/python/typeshed/pull/10253#discussion_r1216712404 # https://github.com/python/typeshed/pull/9734 - with tempfile.NamedTemporaryFile("w+") as temp: + with tempfile.NamedTemporaryFile("w+", encoding="utf8", suffix=".ini") as temp: temp.write("[mypy]\ndisable_error_code = overload-overlap") temp.flush() diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 8657e1c317ec..a46f4dc1c8cc 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -101,7 +101,10 @@ def run_stubtest( modules_to_check = [d.stem for d in dist.iterdir() if d.is_file() and d.suffix == ".pyi"] config_file = Path(tmp, "mypy.ini") - config_file.write_text("[mypy]\ndisable_error_code = overload-overlap") + config_file.write_text( + "[mypy]\ndisable_error_code = overload-overlap", + encoding="utf8", + ) stubtest_cmd = [ python_exe,