diff options
author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2019-03-23 22:31:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-23 22:31:52 -0700 |
commit | da01262b8f03b70e889d3b1255e041978f6d40d9 (patch) | |
tree | c9b01ae616fdc5f1fe538e5b587087ba4859a28e | |
parent | fab9d505ecc4a805ddc922f76e9e23679adf672e (diff) | |
parent | cf2e435a420133d0ac87ba342c268647bf0c6bb1 (diff) | |
download | isort-da01262b8f03b70e889d3b1255e041978f6d40d9.tar.gz |
Merge pull request #911 from timothycrosley/feature/fix-issue-909
Feature/fix issue 909
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | isort/main.py | 3 | ||||
-rw-r--r-- | test_isort.py | 35 |
3 files changed, 38 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 85638132..d656640d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ Changelog ========= +### 4.3.16 - March 23, 2019 - hot fix release +- Fixed issue #909 - skip and skip-glob are not enforced when using settings-path + ### 4.3.15 - March 10, 2019 - hot fix release - Fixed a regression with handling streaming input from pipes (Issue #895) - Fixed handling of \x0c whitespace character (Issue #811) diff --git a/isort/main.py b/isort/main.py index 24de5c0c..8c3ec9a3 100644 --- a/isort/main.py +++ b/isort/main.py @@ -345,7 +345,8 @@ def main(argv=None): arguments['recursive'] = True if not arguments.get('apply', False): arguments['ask_to_apply'] = True - config = from_path(os.path.abspath(file_names[0]) or os.getcwd()).copy() + + config = from_path(arguments.get('settings_path', '') or os.path.abspath(file_names[0]) or os.getcwd()).copy() config.update(arguments) wrong_sorted_files = False skipped = [] diff --git a/test_isort.py b/test_isort.py index 8c157c4e..1e75c17e 100644 --- a/test_isort.py +++ b/test_isort.py @@ -23,21 +23,22 @@ OTHER DEALINGS IN THE SOFTWARE. """ from __future__ import absolute_import, division, print_function, unicode_literals -from tempfile import NamedTemporaryFile import io import os import os.path import posixpath import sys import sysconfig +from subprocess import check_output +from tempfile import NamedTemporaryFile import pytest from isort import finders, main, settings from isort.isort import SortImports -from isort.utils import exists_case_sensitive from isort.main import is_python_file from isort.settings import WrapModes +from isort.utils import exists_case_sensitive try: import toml @@ -2888,3 +2889,33 @@ def test_to_ensure_correctly_handling_of_whitespace_only_issue_811(capsys): out, err = capsys.readouterr() assert out == '' assert err == '' + + +def test_settings_path_skip_issue_909(tmpdir): + base_dir = tmpdir.mkdir('project') + config_dir = base_dir.mkdir('conf') + config_dir.join('.isort.cfg').write('[isort]\n' + 'skip =\n' + ' file_to_be_skipped.py\n' + 'skip_glob =\n' + ' *glob_skip*\n') + + base_dir.join('file_glob_skip.py').write('import os\n' + '\n' + 'print("Hello World")\n' + '\n' + 'import sys\n') + base_dir.join('file_to_be_skipped.py').write('import os\n' + '\n' + 'print("Hello World")' + '\n' + 'import sys\n') + + test_run_directory = os.getcwd() + os.chdir(str(base_dir)) + with pytest.raises(Exception): # without the settings path provided: the command should not skip & identify errors + check_output(['isort', '--check-only']) + results = check_output(['isort', '--check-only', '--settings-path=conf/.isort.cfg']) + os.chdir(str(test_run_directory)) + + assert b'skipped 2' in results.lower() |