diff --git a/util/check_style.py b/util/check_style.py index 97b7c1ba58c..437446092f5 100644 --- a/util/check_style.py +++ b/util/check_style.py @@ -78,7 +78,7 @@ def _check_style(file_path, clang_format_bin): """ Returns (true, true) if (style, header) is valid. """ - with open(file_path, 'r') as f: + with open(file_path, 'r', encoding='utf-8') as f: is_valid_header = f.read().startswith(CppFormatter.standard_header) cmd = [ @@ -156,7 +156,7 @@ def _check_style(file_path, style_config): Returns (true, true) if (style, header) is valid. """ - with open(file_path, 'r') as f: + with open(file_path, 'r', encoding='utf-8') as f: content = f.read() is_valid_header = (len(content) == 0 or content.startswith( PythonFormatter.standard_header)) @@ -218,7 +218,7 @@ def _check_or_apply_style(file_path, style_config, apply): are merged into one. """ # Ref: https://gist.github.com/oskopek/496c0d96c79fb6a13692657b39d7c709 - with open(file_path, "r") as f: + with open(file_path, "r", encoding='utf-8') as f: notebook = nbformat.read(f, as_version=nbformat.NO_CONVERT) nbformat.validate(notebook) @@ -241,7 +241,7 @@ def _check_or_apply_style(file_path, style_config, apply): changed = True if apply: - with open(file_path, "w") as f: + with open(file_path, "w", encoding='utf-8') as f: nbformat.write(notebook, f, version=nbformat.NO_CONVERT) return not changed @@ -444,4 +444,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file