Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update check_style.py #6443

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions util/check_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down