diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-03-03 23:05:32 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-03-03 23:05:32 -0800 |
commit | 373bc3c1ac59ded179261042f05b079b0f9acba1 (patch) | |
tree | f1c2904fdc6585b30a6a4249556ac3305aece914 /isort/compat.py | |
parent | 115d2dd6a94037ebfe8bb449985181a1cd49d733 (diff) | |
download | isort-373bc3c1ac59ded179261042f05b079b0f9acba1.tar.gz |
Update to fix mypy and black linting errors
Diffstat (limited to 'isort/compat.py')
-rw-r--r-- | isort/compat.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/isort/compat.py b/isort/compat.py index d3c0eb59..5a8a7176 100644 --- a/isort/compat.py +++ b/isort/compat.py @@ -7,7 +7,7 @@ from warnings import warn from . import api from .exceptions import ExistingSyntaxErrors, FileSkipped, IntroducedSyntaxErrors from .format import ask_whether_to_apply_changes_to_file, show_unified_diff -from .io import File +from .io import File, read_file from .settings import Config @@ -34,11 +34,14 @@ class SortImports: if filename: if file_contents: file_data = File.from_contents(file_contents, filename=filename) + file_stream, file_path, file_encoding = file_data + if not extension: + extension = file_data.extension else: - file_data = File.read(filename) - file_stream, file_path, file_encoding = file_data - if not extension: - extension = file_data.extension + with read_file(filename) as file_data: + file_stream, file_path, file_encoding = file_data + if not extension: + extension = file_data.extension else: file_stream = StringIO(file_contents) |