Skip to content

Commit 7794e36

Browse files
committed
lint: Use black and isort for py files.
1 parent 63fefd2 commit 7794e36

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
ignore =
33
# Each of these rules are ignored for the explained reason.
44

5+
# "whitespace before ':'"
6+
# Black disagrees with this.
7+
E203,
8+
59
# "multiple spaces before operator"
610
# There are several typos here, but also several instances that are
711
# being used for alignment in dict keys/values using the `dict`

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.black]
2+
line-length = 100
3+
target-version = ["py36"]
4+
5+
[tool.isort]
6+
src_paths = [".", "tools"]
7+
known_third_party = "zulip"
8+
profile = "black"
9+
line_length = 100

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
crayons
22
twine
33
coverage>=4.4.1
4+
black
5+
isort
46
flake8
57
mock
68
pytest

tools/lint

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import argparse
44
import sys
5+
import re
56

67
from zulint.command import add_default_linter_arguments, LinterConfig
78

@@ -28,6 +29,14 @@ def run() -> None:
2829
description="Standard Python linter (config: .flake8)")
2930
linter_config.external_linter('gitlint', ['tools/lint-commits'],
3031
description="Git Lint for commit messages")
32+
linter_config.external_linter("isort", ["isort"], ["py"],
33+
description="Sorts Python import statements",
34+
check_arg=["--check-only", "--diff"])
35+
linter_config.external_linter("black", ["black"], ["py"],
36+
description="Reformats Python code",
37+
check_arg=["--check"],
38+
suppress_line=lambda line: line == "All done! ✨ 🍰 ✨\n"
39+
or re.fullmatch(r"\d+ files? would be left unchanged\.\n", line) is not None)
3140

3241
@linter_config.lint
3342
def custom_py() -> int:

0 commit comments

Comments
 (0)