Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/1482/fix pylama integration #1484

Merged
merged 5 commits into from Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cruft.json
@@ -1,6 +1,6 @@
{
"template": "https://github.com/timothycrosley/cookiecutter-python/",
"commit": "4fe165a760a98a06d3fbef89aae3149767e489f3",
"commit": "ff6836bfaa247c65ff50b39c520ed12d91bf5a20",
"context": {
"cookiecutter": {
"full_name": "Timothy Crosley",
Expand All @@ -13,4 +13,4 @@
}
},
"directory": ""
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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.
Expand Down
22 changes: 16 additions & 6 deletions isort/pylama_isort.py
Expand Up @@ -5,6 +5,8 @@

from pylama.lint import Linter as BaseLinter

from isort.exceptions import FileSkipped

from . import api


Expand All @@ -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 []
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -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/"
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_pylama_isort.py
Expand Up @@ -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))