From fc8f7841203abaf8d557ceecadc19c175138d31f Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 14 Sep 2020 23:17:35 -0700 Subject: [PATCH 1/5] Fix plugin definition to match pylama expectation --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31e126565..4b3bdff4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ isort = "isort.main:main" isort = "isort.main:ISortCommand" [tool.poetry.plugins."pylama.linter"] -isort = "isort = isort.pylama_isort:Linter" +isort = "isort.pylama_isort:Linter" [tool.portray.mkdocs] edit_uri = "https://github.com/pycqa/isort/edit/develop/" From 7d6580f2eb0e142a7ff7c77e6fc1d75f2a3d71b3 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 14 Sep 2020 23:19:05 -0700 Subject: [PATCH 2/5] Fix pylama integration to work with file skip comments --- isort/pylama_isort.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/isort/pylama_isort.py b/isort/pylama_isort.py index 0e14d5696..4d4ffb922 100644 --- a/isort/pylama_isort.py +++ b/isort/pylama_isort.py @@ -5,6 +5,8 @@ from pylama.lint import Linter as BaseLinter +from isort.exceptions import FileSkipped + from . import api @@ -25,9 +27,17 @@ def allow(self, path: str) -> bool: def run(self, path: str, **meta: Any) -> List[Dict[str, Any]]: """Lint the file. Return an array of error dicts if appropriate.""" with supress_stdout(): - if not api.check_file(path): - return [ - {"lnum": 0, "col": 0, "text": "Incorrectly sorted imports.", "type": "ISORT"} - ] - else: - return [] + try: + if not api.check_file(path, disregard_skip=False): + return [ + { + "lnum": 0, + "col": 0, + "text": "Incorrectly sorted imports.", + "type": "ISORT", + } + ] + except FileSkipped: + pass + + return [] From d34620af3434aeb42aa98cf17af5d9dcec18b89d Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 14 Sep 2020 23:19:39 -0700 Subject: [PATCH 3/5] Update to latest cruft --- .cruft.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cruft.json b/.cruft.json index f70213bc6..dcbd6c8eb 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/timothycrosley/cookiecutter-python/", - "commit": "4fe165a760a98a06d3fbef89aae3149767e489f3", + "commit": "ff6836bfaa247c65ff50b39c520ed12d91bf5a20", "context": { "cookiecutter": { "full_name": "Timothy Crosley", @@ -13,4 +13,4 @@ } }, "directory": "" -} +} \ No newline at end of file From 48081a925d5b69e18a1f04c74cbe98b590e77c5b Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 14 Sep 2020 23:26:48 -0700 Subject: [PATCH 4/5] Add a test for skip functionality --- tests/unit/test_pylama_isort.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/test_pylama_isort.py b/tests/unit/test_pylama_isort.py index b7b78c138..1fe19bfa1 100644 --- a/tests/unit/test_pylama_isort.py +++ b/tests/unit/test_pylama_isort.py @@ -17,3 +17,8 @@ def test_run(self, src_dir, tmpdir): incorrect = tmpdir.join("incorrect.py") incorrect.write("import b\nimport a\n") assert self.instance.run(str(incorrect)) + + def test_skip(self, src_dir, tmpdir): + incorrect = tmpdir.join("incorrect.py") + incorrect.write("# isort: skip_file\nimport b\nimport a\n") + assert not self.instance.run(str(incorrect)) From 226f18ab0a2cfde43748aeb577e77a4bc02ba598 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 14 Sep 2020 23:27:55 -0700 Subject: [PATCH 5/5] Mark Fix #1482: pylama integration - in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96503547c..ac76e56ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/ - Improved handling of unsupported configuration option errors (see #1475). - Fixed #1463: Better interactive documentation for future option. - Fixed #1461: Quiet config option not respected by file API in some circumstances. + - Fixed #1482: pylama integration is not working correctly out-of-the-box. ### 5.5.2 [Hotfix] September 9, 2020 - Fixed #1469: --diff option is ignored when input is from stdin.