diff options
author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2019-04-25 22:32:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 22:32:57 -0700 |
commit | 236c13a042b695d35d7991d397d3855f94213a92 (patch) | |
tree | f36a1dfd148fe74f2584a5b5db00c3c11e30ff49 | |
parent | 7b731926c3aee7615786343e619bb6f97fc3ebf9 (diff) | |
parent | 4c20eb67a72a72a5634ca0eda7db39f7a7f6a267 (diff) | |
download | isort-236c13a042b695d35d7991d397d3855f94213a92.tar.gz |
Merge pull request #932 from mkurnikov/public-api
Make compat layer to preserve public api
-rw-r--r-- | isort/__init__.py | 2 | ||||
-rw-r--r-- | isort/compat.py | 45 | ||||
-rw-r--r-- | isort/isort.py | 2 | ||||
-rw-r--r-- | isort/pylama_isort.py | 2 | ||||
-rw-r--r-- | test_isort.py | 3 |
5 files changed, 49 insertions, 5 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..07da7371 --- /dev/null +++ b/isort/compat.py @@ -0,0 +1,45 @@ +from typing import Any, Optional + +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/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 |