From bc2a889a19a66f70d7be9099a9e80f08b5ddc1bf Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 14 Sep 2021 22:14:55 +0100 Subject: [PATCH 1/2] Read config files as UTF-8 when finding line numbers. --- mypy/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/build.py b/mypy/build.py index f3df5f18f54d..e636b606ed8f 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -511,7 +511,7 @@ def find_config_file_line_number(path: str, section: str, setting_name: str) -> in_desired_section = False try: results = [] - with open(path) as f: + with open(path, encoding="UTF-8") as f: for i, line in enumerate(f): line = line.strip() if line.startswith('[') and line.endswith(']'): From 5cf00f9173856803bd377a57f1cb8bd3bf1a9ed4 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Wed, 15 Sep 2021 12:28:11 +0100 Subject: [PATCH 2/2] Add test case for Unicode in PyProject.toml --- test-data/unit/cmdline.pyproject.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test-data/unit/cmdline.pyproject.test b/test-data/unit/cmdline.pyproject.test index ea561ed164e7..831bce2eb63d 100644 --- a/test-data/unit/cmdline.pyproject.test +++ b/test-data/unit/cmdline.pyproject.test @@ -125,3 +125,11 @@ i: int = 0 This isn't even syntatically valid! [file x/please_skipme_.py] Neither is this! + +[case testPyprojectTOMLUnicode] +# cmd: mypy x.py +[file pyproject.toml] +\[project] +description = "Factory ⸻ A code generator 🏭" +\[tool.mypy] +[file x.py]