Skip to content

Commit 3cc8b79

Browse files
committed
configure isort, black & pre-commit
1 parent ce913f1 commit 3cc8b79

File tree

5 files changed

+71
-8
lines changed

5 files changed

+71
-8
lines changed

.github/workflows/static.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ jobs:
3535
python-version: '3.7'
3636
architecture: 'x64'
3737
- run: python -m pip install --upgrade pip setuptools jsonschema
38-
- run: pip install -e .[pylint,pycodestyle,pyflakes]
39-
- name: Pylint checks
40-
run: pylint pylsp test
41-
- name: Code style checks
42-
run: pycodestyle pylsp test
43-
- name: Pyflakes checks
44-
run: pyflakes pylsp test
38+
- run: pip install -e .[lint]
39+
- name: run linters via pre-commit
40+
run: |
41+
pre-commit run --all --show-diff-on-failure --color=always
4542
- name: Validate JSON schema
4643
run: echo {} | jsonschema pylsp/config/schema.json
4744
- name: Ensure JSON schema and Markdown docs are in sync

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: debug-statements
8+
- id: check-added-large-files
9+
- repo: local
10+
hooks:
11+
- id: isort
12+
name: isort
13+
entry: isort
14+
language: system
15+
types:
16+
- python
17+
- id: black
18+
name: black
19+
entry: black
20+
language: system
21+
types:
22+
- python
23+
- id: pyflakes
24+
name: pyflakes
25+
entry: pyflakes
26+
language: system
27+
types:
28+
- python
29+
- id: pylint
30+
name: pylint
31+
entry: pylint
32+
language: system
33+
types:
34+
- python
35+
- id: pycodestyle
36+
name: pycodestyle
37+
entry: pycodestyle
38+
language: system
39+
types:
40+
- python

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ To run the test suite:
161161
pip install ".[test]" && pytest
162162
```
163163

164+
To run the linters:
165+
```sh
166+
pip install ".[lint]" && pre-commit run --all
167+
```
168+
You can also locally run `pre-commit install` in your repo to run
169+
linters on changed files when committing.
170+
164171
After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with
165172

166173
```

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ all = [
4040
]
4141
autopep8 = ["autopep8>=1.6.0,<1.7.0"]
4242
flake8 = ["flake8>=5.0.0,<7"]
43+
isort = ["isort>=5.11.4,<6"]
44+
black = ["black>=22.12.0,<23"]
4345
mccabe = ["mccabe>=0.7.0,<0.8.0"]
46+
pre-commit = ["pre-commit>=2.21.0,<3.0.0"]
4447
pycodestyle = ["pycodestyle>=2.9.0,<2.11.0"]
4548
pydocstyle = ["pydocstyle>=6.2.0,<6.3.0"]
4649
pyflakes = ["pyflakes>=2.5.0,<3.1.0"]
@@ -59,6 +62,14 @@ test = [
5962
"pyqt5",
6063
"flaky",
6164
]
65+
lint = [
66+
"isort",
67+
"black",
68+
"pre-commit",
69+
"pylint",
70+
"pycodestyle",
71+
"pyflakes",
72+
]
6273

6374
[project.entry-points.pylsp]
6475
autopep8 = "pylsp.plugins.autopep8_format"
@@ -105,3 +116,11 @@ addopts = "--cov-report html --cov-report term --junitxml=pytest.xml --cov pylsp
105116
[tool.coverage.run]
106117
concurrency = ["multiprocessing", "thread"]
107118

119+
[tool.isort]
120+
profile = "black"
121+
src_paths = ["pylsp", "test"]
122+
line_length = 120
123+
124+
[tool.black]
125+
line-length = 120
126+
target-version = ['py37']

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# Copyright 2021- Python Language Server Contributors.
33

44
[pycodestyle]
5-
ignore = E226, E722, W504
5+
ignore = E226, E722, W504, W503, E203
66
max-line-length = 120
77
exclude = test/plugins/.ropeproject,test/.ropeproject

0 commit comments

Comments
 (0)