Skip to content

Commit 4292c4a

Browse files
committed
Add UTF8 support, fixes #158
1 parent 0287c4a commit 4292c4a

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

gdtoolkit/formatter/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _check_files_formatting(
8686
failed_files = set()
8787
for file_path in files:
8888
try:
89-
with open(file_path, "r") as fh:
89+
with open(file_path, "r", encoding="utf-8") as fh:
9090
code = fh.read()
9191
success, actually_formatted, formatted_code = _format_code(
9292
code, line_length, file_path, safety_checks
@@ -141,7 +141,7 @@ def _format_files(files: List[str], line_length: int, safety_checks: bool) -> No
141141
failed_files = set()
142142
for file_path in files:
143143
try:
144-
with open(file_path, "r+") as fh:
144+
with open(file_path, "r+", encoding="utf-8") as fh:
145145
code = fh.read()
146146
success, actually_formatted, formatted_code = _format_code(
147147
code, line_length, file_path, safety_checks

gdtoolkit/gd2py/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ def main():
3030
__doc__,
3131
version="gd2py {}".format(pkg_resources.get_distribution("gdtoolkit").version),
3232
)
33-
with open(arguments["<path>"], "r") as fh:
33+
with open(arguments["<path>"], "r", encoding="utf-8") as fh:
3434
print(convert_code(fh.read()))

gdtoolkit/gdradon/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main():
4343

4444
def _cc(file_path: str) -> None:
4545
try:
46-
with open(file_path, "r") as fh:
46+
with open(file_path, "r", encoding="utf-8") as fh:
4747
python_code = convert_code(fh.read())
4848
results = cc_visit(python_code)
4949
if results == []:

gdtoolkit/linter/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def main():
8080
def _dump_default_config() -> None:
8181
# TODO: error handling
8282
assert not os.path.isfile(CONFIG_FILE_NAME)
83-
with open(CONFIG_FILE_NAME, "w") as fh:
83+
with open(CONFIG_FILE_NAME, "w", encoding="utf-8") as fh:
8484
fh.write(yaml.dump(DEFAULT_CONFIG.copy()))
8585
sys.exit(0)
8686

@@ -105,7 +105,7 @@ def _load_config_file_or_default(config_file_path: Optional[str]) -> MappingProx
105105
# TODO: error handling
106106
if config_file_path is not None:
107107
logging.info("Config file found: '%s'", config_file_path)
108-
with open(config_file_path, "r") as fh:
108+
with open(config_file_path, "r", encoding="utf-8") as fh:
109109
return yaml.load(fh.read(), Loader=yaml.Loader)
110110

111111
logging.info("""No 'gdlintrc' nor '.gdlintrc' found. Using default config...""")
@@ -129,7 +129,7 @@ def _update_config_with_missing_entries_inplace(config: dict) -> None:
129129

130130
def _lint_file(file_path: str, config: MappingProxyType) -> int:
131131
try:
132-
with open(file_path, "r") as fh:
132+
with open(file_path, "r", encoding="utf-8") as fh:
133133
content = fh.read()
134134
problems = lint_code(content, config)
135135
if len(problems) > 0: # TODO: friendly frontend like in halint

gdtoolkit/parser/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main():
5050

5151
def _parse_file(file_path: str, arguments: Dict) -> bool:
5252
try:
53-
with open(file_path, "r") as fh:
53+
with open(file_path, "r", encoding="utf-8") as fh:
5454
file_content = fh.read()
5555
return _parse_file_content(file_content, arguments, file_path)
5656
except OSError as e:

0 commit comments

Comments
 (0)