Skip to content

Commit

Permalink
Add unicode to check style (#6443)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrishastin authored Oct 24, 2023
1 parent a2401d0 commit fa1a16c
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit fa1a16c

Please sign in to comment.