Skip to content

Commit 306275f

Browse files
committed
lint: Use isort for py files.
1 parent 63fefd2 commit 306275f

File tree

163 files changed

+524
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+524
-428
lines changed

pyproject.toml

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

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
crayons
22
twine
33
coverage>=4.4.1
4+
isort
45
flake8
56
mock
67
pytest

tools/custom_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import List
2+
23
from zulint.custom_rules import RuleList
34

45
MYPY = False

tools/deploy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env python3
22

3-
from typing import Any, List, Dict, Callable
4-
3+
import argparse
54
import os
65
import sys
7-
import argparse
8-
import zipfile
96
import textwrap
10-
import requests
117
import urllib.parse
8+
import zipfile
9+
from typing import Any, Callable, Dict, List
10+
11+
import requests
1212
from requests import Response
1313

1414
red = '\033[91m' # type: str

tools/lint

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import argparse
44
import sys
55

6-
from zulint.command import add_default_linter_arguments, LinterConfig
6+
from zulint.command import LinterConfig, add_default_linter_arguments
77

8-
from custom_check import python_rules, non_py_rules
8+
from custom_check import non_py_rules, python_rules
99

1010
EXCLUDED_FILES = [
1111
# This is an external file that doesn't comply with our codestyle
@@ -28,6 +28,9 @@ def run() -> None:
2828
description="Standard Python linter (config: .flake8)")
2929
linter_config.external_linter('gitlint', ['tools/lint-commits'],
3030
description="Git Lint for commit messages")
31+
linter_config.external_linter("isort", ["isort"], ["py"],
32+
description="Sorts Python import statements",
33+
check_arg=["--check-only", "--diff"])
3134

3235
@linter_config.lint
3336
def custom_py() -> int:

tools/provision

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python3
22

3-
import os
4-
import sys
53
import argparse
6-
import subprocess
74
import glob
5+
import os
6+
import subprocess
7+
import sys
88

99
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
1010
ZULIP_BOTS_DIR = os.path.join(CURRENT_DIR, '..', 'zulip_bots')

tools/release-packages

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env python3
22

3-
from contextlib import contextmanager
4-
import os
53
import argparse
64
import glob
5+
import os
76
import shutil
87
import tempfile
8+
from contextlib import contextmanager
99

1010
import crayons
11-
import twine.commands.upload
1211
import setuptools.sandbox
12+
import twine.commands.upload
1313

1414
REPO_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1515

tools/review

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import sys
55

6+
67
def exit(message: str) -> None:
78
print('PROBLEM!')
89
print(message)

tools/run-mypy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env python3
22

3-
import os
4-
import sys
53
import argparse
4+
import os
65
import subprocess
7-
6+
import sys
87
from collections import OrderedDict
98
from pathlib import PurePath
9+
from typing import Dict, List, cast
10+
1011
from zulint import lister
11-
from typing import cast, Dict, List
1212

1313
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
1414
os.chdir(os.path.dirname(TOOLS_DIR))

tools/server_lib/test_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

2+
import argparse
23
import os
4+
import shutil
35
import sys
4-
import argparse
56
import unittest
7+
68
import pytest
7-
import shutil
89

910
TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1011
os.chdir(os.path.dirname(TOOLS_DIR))

0 commit comments

Comments
 (0)