Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

lint: Run isort as a linter.

Anders Kaseorg48e55875fe69
diff --git a/.isort.cfg b/.isort.cfg
index dc8638df4f0..a58ddc8a8d4 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -3,4 +3,4 @@ multi_line_output = 3
known_third_party = netifaces
include_trailing_comma = True
use_parentheses = True
-line_length = 88
+line_length = 100
diff --git a/tools/lint b/tools/lint
index 2c379c83e5d..0b5801e3d36 100755
--- a/tools/lint
+++ b/tools/lint
@@ -89,6 +89,9 @@ def run() -> None:
linter_config.external_linter('gitlint', ['tools/commit-message-lint'],
description="Checks commit messages for common formatting errors."
"(config: .gitlint)")
+ linter_config.external_linter('isort', ['tools/run-isort'], ['py'],
+ description="Sorts Python import statements",
+ fix_arg='--fix')
semgrep_command = ["semgrep", "--config=./tools/semgrep.yml", "--error",
# This option is dangerous in the context of running
diff --git a/tools/run-isort b/tools/run-isort
new file mode 100755
index 00000000000..016521891af
--- /dev/null
+++ b/tools/run-isort
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -eu
+if [ "$1" = "--fix" ]; then
+ shift
+ exec isort "$@"
+else
+ exec isort --check-only --diff "$@"
+fi