summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kurnikov <maxim.kurnikov@gmail.com>2019-04-25 13:32:48 +0300
committerMaxim Kurnikov <maxim.kurnikov@gmail.com>2019-04-25 13:32:48 +0300
commit9ccfadd207cfd8390ff365d1f9a082762746633c (patch)
tree2a9de80b43938159238dbae1807d35aee750a2d5
parent7b731926c3aee7615786343e619bb6f97fc3ebf9 (diff)
downloadisort-9ccfadd207cfd8390ff365d1f9a082762746633c.tar.gz
make compat layer to preserve public api
-rw-r--r--isort/__init__.py2
-rw-r--r--isort/compat.py45
-rw-r--r--isort/isort.py2
-rw-r--r--isort/main.py2
-rw-r--r--isort/pylama_isort.py2
-rw-r--r--test_isort.py3
6 files changed, 50 insertions, 6 deletions
diff --git a/isort/__init__.py b/isort/__init__.py
index 4314b858..dd113998 100644
--- a/isort/__init__.py
+++ b/isort/__init__.py
@@ -20,6 +20,6 @@ OTHER DEALINGS IN THE SOFTWARE.
"""
from . import settings # noqa: F401
-from .isort import SortImports # noqa: F401
+from .compat import SortImports # noqa: F401
__version__ = "4.3.17"
diff --git a/isort/compat.py b/isort/compat.py
new file mode 100644
index 00000000..e7a8b45d
--- /dev/null
+++ b/isort/compat.py
@@ -0,0 +1,45 @@
+from typing import Optional, Any
+
+from isort.isort import _SortImports
+
+
+class SortImports(object):
+ def __init__(
+ self,
+ file_path: Optional[str] = None,
+ file_contents: Optional[str] = None,
+ write_to_stdout: bool = False,
+ check: bool = False,
+ show_diff: bool = False,
+ settings_path: Optional[str] = None,
+ ask_to_apply: bool = False,
+ run_path: str = '',
+ check_skip: bool = True,
+ **setting_overrides: Any
+ ):
+ self.sorted_imports = _SortImports(file_path, file_contents, write_to_stdout, check, show_diff, settings_path,
+ ask_to_apply, run_path, check_skip, **setting_overrides)
+
+ @property
+ def config(self):
+ return self.sorted_imports.config
+
+ @property
+ def sections(self):
+ return self.sorted_imports.sections
+
+ @property
+ def incorrectly_sorted(self):
+ return self.sorted_imports.incorrectly_sorted
+
+ @property
+ def skipped(self) -> bool:
+ return self.sorted_imports.skipped
+
+ @property
+ def length_change(self) -> int:
+ return self.sorted_imports.length_change
+
+ @property
+ def output(self):
+ return self.sorted_imports.output
diff --git a/isort/isort.py b/isort/isort.py
index 94c61341..4df1808c 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -56,7 +56,7 @@ if TYPE_CHECKING:
})
-class SortImports(object):
+class _SortImports(object):
incorrectly_sorted = False
skipped = False
diff --git a/isort/main.py b/isort/main.py
index 17d2471b..211b0557 100644
--- a/isort/main.py
+++ b/isort/main.py
@@ -27,7 +27,7 @@ from typing import Any, Dict, Iterable, Iterator, List, MutableMapping, Optional
import setuptools
-from isort import SortImports, __version__
+from isort import __version__, SortImports
from isort.settings import DEFAULT_SECTIONS, WrapModes, default, file_should_be_skipped, from_path
INTRO = r"""
diff --git a/isort/pylama_isort.py b/isort/pylama_isort.py
index 9248981e..a8e508e9 100644
--- a/isort/pylama_isort.py
+++ b/isort/pylama_isort.py
@@ -4,7 +4,7 @@ from typing import Any, Dict, List
from pylama.lint import Linter as BaseLinter
-from .isort import SortImports
+from . import SortImports
class Linter(BaseLinter):
diff --git a/test_isort.py b/test_isort.py
index 68367885..d68033dd 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -34,8 +34,7 @@ import py
import pytest
from isort import finders, main, settings
-from isort.isort import SortImports
-from isort.main import is_python_file
+from isort.main import is_python_file, SortImports
from isort.settings import WrapModes
from isort.utils import exists_case_sensitive