diff --git a/pre_commit_hooks/autopep8_wrapper.py b/pre_commit_hooks/autopep8_wrapper.py index 52aaebe..f0a83d2 100644 --- a/pre_commit_hooks/autopep8_wrapper.py +++ b/pre_commit_hooks/autopep8_wrapper.py @@ -2,7 +2,6 @@ from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals -import io import sys import autopep8 @@ -14,12 +13,12 @@ def main(argv=None): retv = 0 for filename in args.files: - original_contents = io.open(filename).read() + original_contents = open(filename).read() new_contents = autopep8.fix_code(original_contents, args) if original_contents != new_contents: print('Fixing {}'.format(filename)) retv = 1 - with io.open(filename, 'w') as output_file: + with open(filename, 'w') as output_file: output_file.write(new_contents) return retv diff --git a/pre_commit_hooks/check_docstring_first.py b/pre_commit_hooks/check_docstring_first.py index 8e658a1..5b622e0 100644 --- a/pre_commit_hooks/check_docstring_first.py +++ b/pre_commit_hooks/check_docstring_first.py @@ -57,7 +57,7 @@ def main(argv=None): retv = 0 for filename in args.filenames: - contents = io.open(filename).read() + contents = open(filename).read() retv |= check_docstring_first(contents, filename=filename) return retv diff --git a/pre_commit_hooks/check_xml.py b/pre_commit_hooks/check_xml.py index a4c11a5..0cc2894 100644 --- a/pre_commit_hooks/check_xml.py +++ b/pre_commit_hooks/check_xml.py @@ -3,7 +3,6 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import io import sys import xml.sax @@ -16,7 +15,7 @@ def check_xml(argv=None): retval = 0 for filename in args.filenames: try: - with io.open(filename, 'rb') as xml_file: + with open(filename, 'rb') as xml_file: xml.sax.parse(xml_file, xml.sax.ContentHandler()) except xml.sax.SAXException as exc: print('{}: Failed to xml parse ({})'.format(filename, exc)) diff --git a/pre_commit_hooks/string_fixer.py b/pre_commit_hooks/string_fixer.py index 3523e8a..a91f254 100644 --- a/pre_commit_hooks/string_fixer.py +++ b/pre_commit_hooks/string_fixer.py @@ -32,7 +32,7 @@ def get_line_offsets_by_line_no(src): def fix_strings(filename): - contents = io.open(filename).read() + contents = open(filename).read() line_offsets = get_line_offsets_by_line_no(contents) # Basically a mutable string @@ -52,7 +52,7 @@ def fix_strings(filename): new_contents = ''.join(splitcontents) if contents != new_contents: - with io.open(filename, 'w') as write_handle: + with open(filename, 'w') as write_handle: write_handle.write(new_contents) return 1 else: diff --git a/testing/util.py b/testing/util.py index 837a3cb..ad179f6 100644 --- a/testing/util.py +++ b/testing/util.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from __future__ import unicode_literals -import io import os.path @@ -14,5 +13,5 @@ def get_resource_path(path): def write_file(filename, contents): """Hax because coveragepy chokes on nested context managers.""" - with io.open(filename, 'w', newline='') as file_obj: + with open(filename, 'w', newline='') as file_obj: file_obj.write(contents) diff --git a/tests/readme_test.py b/tests/readme_test.py index 4d4c972..b48260f 100644 --- a/tests/readme_test.py +++ b/tests/readme_test.py @@ -1,13 +1,11 @@ from __future__ import absolute_import from __future__ import unicode_literals -import io - import yaml def test_readme_contains_all_hooks(): - readme_contents = io.open('README.md').read() - hooks = yaml.load(io.open('hooks.yaml').read()) + readme_contents = open('README.md').read() + hooks = yaml.load(open('hooks.yaml').read()) for hook in hooks: assert '`{}`'.format(hook['id']) in readme_contents