Replace io.open() with just open() (#28890)
In Python 3, io.open() is an alias for the builtin open() function:
https://docs.python.org/3/library/io.html#io.open
Part of https://github.com/web-platform-tests/wpt/issues/28776.
diff --git a/tools/ci/tc/github_checks_output.py b/tools/ci/tc/github_checks_output.py
index fcc6f8c..a198bd4 100644
--- a/tools/ci/tc/github_checks_output.py
+++ b/tools/ci/tc/github_checks_output.py
@@ -1,4 +1,3 @@
-import io
from six import ensure_text
MYPY = False
@@ -23,11 +22,7 @@
def output(self, line):
# type: (AnyStr) -> None
text = ensure_text(line)
- # NOTE: mypy types the "text mode" of open() in Python 2 as BinaryIO,
- # which makes sense as we cannot specify its encoding (it's
- # platform-dependent), while io.open() is closer to open() in Python 3.
- # TODO: use the built-in open() when we are Py3-only.
- with io.open(self.path, mode="a") as f:
+ with open(self.path, mode="a") as f:
f.write(text)
f.write(u"\n")
diff --git a/tools/ci/tc/tests/test_valid.py b/tools/ci/tc/tests/test_valid.py
index c8a880a..6db20a4 100644
--- a/tools/ci/tc/tests/test_valid.py
+++ b/tools/ci/tc/tests/test_valid.py
@@ -1,6 +1,5 @@
import json
import os
-from io import open
import jsone
import mock
diff --git a/tools/lint/lint.py b/tools/lint/lint.py
index e2ac7c5..9edd554 100644
--- a/tools/lint/lint.py
+++ b/tools/lint/lint.py
@@ -3,7 +3,6 @@
import abc
import argparse
import ast
-import io
import json
import logging
import multiprocessing
@@ -833,7 +832,7 @@
:returns: a list of errors found in ``f``
"""
if f is None:
- f = io.open(os.path.join(repo_root, path), 'rb')
+ f = open(os.path.join(repo_root, path), 'rb')
with f:
errors = []
for file_fn in file_lints:
@@ -1016,7 +1015,7 @@
if jobs == 0:
jobs = multiprocessing.cpu_count()
- with io.open(os.path.join(repo_root, "lint.ignore"), "r") as f:
+ with open(os.path.join(repo_root, "lint.ignore"), "r") as f:
ignorelist, skipped_files = parse_ignorelist(f)
if ignore_glob:
diff --git a/tools/manifest/manifest.py b/tools/manifest/manifest.py
index 9f1e902..d9dc5ee 100644
--- a/tools/manifest/manifest.py
+++ b/tools/manifest/manifest.py
@@ -1,4 +1,3 @@
-import io
import os
import sys
from atomicwrites import atomic_write
@@ -360,7 +359,7 @@
else:
logger.debug("Creating new manifest at %s" % manifest)
try:
- with io.open(manifest, "r", encoding="utf-8") as f:
+ with open(manifest, "r", encoding="utf-8") as f:
rv = Manifest.from_json(tests_root,
jsonlib.load(f),
types=types,
diff --git a/tools/wave/configuration_loader.py b/tools/wave/configuration_loader.py
index a94ebcd..dbee6ea 100644
--- a/tools/wave/configuration_loader.py
+++ b/tools/wave/configuration_loader.py
@@ -2,7 +2,6 @@
from __future__ import unicode_literals
import json
import os
-from io import open
from tools.wpt import wpt
diff --git a/tools/wave/network/static_handler.py b/tools/wave/network/static_handler.py
index 0b666ee..2334a09 100644
--- a/tools/wave/network/static_handler.py
+++ b/tools/wave/network/static_handler.py
@@ -2,7 +2,6 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import os
-from io import open
class StaticHandler(object):