Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions fluent.runtime/fluent/runtime/fallback.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import codecs
import os
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -134,7 +133,7 @@ def resources(
path = self.localize_path(os.path.join(root, resource_id), locale)
if not os.path.isfile(path):
continue
content = codecs.open(path, "r", "utf-8").read()
content = open(path, "r", encoding="utf-8").read()
resources.append(FluentParser().parse(content))
if resources:
yield resources
Expand Down
3 changes: 1 addition & 2 deletions fluent.runtime/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import unittest
from .utils import patch_files
import os
import codecs


class TestFileSimulate(unittest.TestCase):
Expand Down Expand Up @@ -38,5 +37,5 @@ def assertFileIs(self, filename, expect_contents):
else:
self.assertTrue(os.path.isfile(filename),
f"Expected {filename} to exist.")
with codecs.open(filename, "r", "utf-8") as f:
with open(filename, "r", encoding="utf-8") as f:
self.assertEqual(f.read(), expect_contents)
7 changes: 6 additions & 1 deletion fluent.runtime/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def patch_files(files: dict):

def then(func):
@mock.patch("os.path.isfile", side_effect=lambda p: _normalize_file_path(p) in files)
@mock.patch("codecs.open", side_effect=lambda p, _, __: StringIO(files[_normalize_file_path(p)]))
@mock.patch(
"builtins.open",
side_effect=lambda p, *a, **kw: StringIO(files[_normalize_file_path(p)]),
)
@functools.wraps(func) # Make ret look like func to later decorators
def ret(*args, **kwargs):
func(*args[:-2], **kwargs)

return ret

return then
3 changes: 1 addition & 2 deletions fluent.syntax/tests/syntax/test_reference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import codecs
import json
import os
import unittest
Expand All @@ -7,7 +6,7 @@


def read_file(path):
with codecs.open(path, "r", encoding="utf-8") as file:
with open(path, "r", encoding="utf-8") as file:
text = file.read()
return text

Expand Down
3 changes: 1 addition & 2 deletions fluent.syntax/tests/syntax/test_structure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import codecs
import json
import os
import unittest
Expand All @@ -7,7 +6,7 @@


def read_file(path):
with codecs.open(path, "r", encoding="utf-8") as file:
with open(path, "r", encoding="utf-8") as file:
text = file.read()
return text

Expand Down
3 changes: 1 addition & 2 deletions tools/fluentfmt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python

import codecs
import sys

from fluent.syntax import parse, serialize
Expand All @@ -9,7 +8,7 @@


def read_file(path):
with codecs.open(path, "r", encoding="utf-8") as file:
with open(path, "r", encoding="utf-8") as file:
text = file.read()
return text

Expand Down
3 changes: 1 addition & 2 deletions tools/parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python

import codecs
import json
import sys

Expand All @@ -10,7 +9,7 @@


def read_file(path):
with codecs.open(path, "r", encoding="utf-8") as file:
with open(path, "r", encoding="utf-8") as file:
text = file.read()
return text

Expand Down
3 changes: 1 addition & 2 deletions tools/serialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python

import codecs
import json
import sys

Expand All @@ -10,7 +9,7 @@


def read_json(path):
with codecs.open(path, "r", encoding="utf-8") as file:
with open(path, "r", encoding="utf-8") as file:
return json.load(file)


Expand Down