Skip to content

Commit ab00c9f

Browse files
committed
enforce isort
1 parent 0c61489 commit ab00c9f

File tree

9 files changed

+36
-18
lines changed

9 files changed

+36
-18
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ jobs:
3838
run: |
3939
# stop the build if black detect any changes
4040
black --check .
41+
- name: Check isort sorting
42+
run: |
43+
# stop the build if isort detect any changes
44+
isort . --check --diff
4145
- name: Test with pytest
4246
run: |
4347
pytest

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ repos:
88
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
99
rev: v1.0.1
1010
hooks:
11-
- id: rst-linter
11+
- id: rst-linter
12+
- repo: https://github.com/pycqa/isort
13+
rev: 5.10.1
14+
hooks:
15+
- id: isort

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Install development dependencies with (you might want to create a virtualenv fir
7878

7979
The project is formatted with `black`_. You can either configure your IDE to automatically format code with it, run it manually (``black .``) or rely on pre-commit (see below) to format files on git commit.
8080

81+
The project is formatted with `isort`_. You can either configure your IDE to automatically sort imports with it, run it manually (``isort .``) or rely on pre-commit (see below) to sort files on git commit.
82+
8183
The project uses two rst tests in order to assure uploadability to pypi: `rst-linter`_ as a pre-commit hook and `rstcheck`_ in a GitHub workflow. This does not catch all errors.
8284

8385
This project uses `pre-commit`_ to enforce code-quality. After cloning the repository install the pre-commit hooks with:
@@ -89,6 +91,7 @@ This project uses `pre-commit`_ to enforce code-quality. After cloning the repos
8991
After that pre-commit will run `all defined hooks`_ on every ``git commit`` and keep you from committing if there are any errors.
9092

9193
.. _black: https://github.com/psf/black
94+
.. _isort: https://github.com/PyCQA/isort
9295
.. _rst-linter: https://github.com/Lucas-C/pre-commit-hooks-markup
9396
.. _rstcheck: https://github.com/myint/rstcheck
9497
.. _pre-commit: https://pre-commit.com/

pylsp_mypy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

pylsp_mypy/plugin.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
77
@author: Richard Kellnberger
88
"""
9-
import re
10-
import tempfile
9+
import ast
10+
import atexit
11+
import collections
12+
import logging
1113
import os
1214
import os.path
15+
import re
16+
import shutil
1317
import subprocess
18+
import tempfile
19+
import warnings
1420
from pathlib import Path
15-
import logging
21+
from typing import IO, Any, Dict, List, Optional
22+
1623
from mypy import api as mypy_api
1724
from pylsp import hookimpl
18-
from pylsp.workspace import Document, Workspace
1925
from pylsp.config.config import Config
20-
from typing import Optional, Dict, Any, IO, List
21-
import atexit
22-
import collections
23-
import warnings
24-
import shutil
25-
import ast
26+
from pylsp.workspace import Document, Workspace
2627

2728
line_pattern: str = r"((?:^[a-z]:)?[^:]+):(?:(\d+):)?(?:(\d+):)? (\w+): (.*)"
2829

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ exclude = '''
1212
| dist
1313
)/
1414
'''
15+
16+
[tool.isort]
17+
profile = "black"
18+
line_length = 100

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ mypy
33
black
44
pre-commit
55
rstcheck
6+
isort

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
from setuptools import setup
3+
34
from pylsp_mypy import _version
45

56
if __name__ == "__main__":

test/test_plugin.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import pytest
1+
import collections
2+
from unittest.mock import Mock
23

3-
from pylsp.workspace import Workspace, Document
4-
from pylsp.config.config import Config
4+
import pytest
55
from pylsp import uris
6-
from unittest.mock import Mock
6+
from pylsp.config.config import Config
7+
from pylsp.workspace import Document, Workspace
8+
79
from pylsp_mypy import plugin
8-
import collections
910

1011
DOC_URI = __file__
1112
DOC_TYPE_ERR = """{}.append(3)
@@ -140,8 +141,8 @@ def test_apply_overrides():
140141

141142
def test_option_overrides(tmpdir, last_diagnostics_monkeypatch, workspace):
142143
import sys
143-
from textwrap import dedent
144144
from stat import S_IRWXU
145+
from textwrap import dedent
145146

146147
sentinel = tmpdir / "ran"
147148

0 commit comments

Comments
 (0)