Skip to content

Commit 585cc02

Browse files
committed
tools: Sort imports with isort & enforce linting via Travis.
This reformats import statements throughout the code as per isort, and ensures the formatting is retained by adding the new linting script to Travis. Travis runs isort on the lowest python version, since the 'atomic' option should ensure valid syntax, which is assumed to be compatible with other supported versions.
1 parent 1b737c3 commit 585cc02

27 files changed

+113
-123
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ cache:
88
matrix:
99
include:
1010
- python: 3.5
11-
name: "CPython 3.5 pytest (default linux)"
11+
name: "CPython 3.5 pytest & isort linting (default linux)"
12+
# Note that running isort on the lowest version should ensure changes are compatible
13+
env: RUN_ISORT_CHECK=yes
1214
- python: 3.6
1315
name: "CPython 3.6 pytest & mypy type-checking (default linux)"
1416
env: RUN_MYPY=yes
@@ -30,6 +32,7 @@ install:
3032
script:
3133
- pipenv run pytest
3234
- if [[ "$RUN_MYPY" == "yes" ]]; then pipenv run pip install -r requirements.txt && pipenv run ./tools/run-mypy; fi
35+
- if [[ "$RUN_ISORT_CHECK" == "yes" ]]; then pipenv run pip install -r requirements.txt && pipenv run ./tools/run-isort-check; fi
3336
after_success:
3437
- pip install codecov
3538
- codecov

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import codecs
12
import os
23
import sys
3-
import codecs
4-
from setuptools import setup, find_packages
4+
5+
from setuptools import find_packages, setup
56
from setuptools.command.test import test as TestCommand
7+
68
from zulipterminal.version import ZT_VERSION
79

810

tests/cli/test_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
2-
from zulipterminal.cli.run import main, in_color, THEMES, get_login_id
2+
3+
from zulipterminal.cli.run import THEMES, get_login_id, in_color, main
34
from zulipterminal.model import ServerConnectionFailure
45
from zulipterminal.version import ZT_VERSION
56

tests/config/test_keys.py

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

33
from zulipterminal.config import keys
44

5+
56
AVAILABLE_COMMANDS = list(keys.KEY_BINDINGS.keys())
67

78
USED_KEYS = {key

tests/config/test_themes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22

33
from zulipterminal.config.themes import (
4-
THEMES, required_styles, all_themes, complete_and_incomplete_themes
4+
THEMES, all_themes, complete_and_incomplete_themes, required_styles,
55
)
66

7+
78
expected_complete_themes = {
89
'default', 'gruvbox', 'light', 'blue'
910
}

tests/conftest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
import pytest
66

7+
from zulipterminal.helper import initial_index as helper_initial_index
78
from zulipterminal.ui_tools.boxes import MessageBox
89
from zulipterminal.ui_tools.buttons import (
9-
StreamButton,
10-
UserButton,
11-
TopicButton,
10+
StreamButton, TopicButton, UserButton,
1211
)
13-
from zulipterminal.helper import initial_index as helper_initial_index
1412

1513

1614
@pytest.fixture(autouse=True)

tests/core/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from zulipterminal.core import Controller
77
from zulipterminal.version import ZT_VERSION
88

9+
910
CORE = "zulipterminal.core"
1011

1112

tests/helper/test_helper.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
from typing import Any
2+
13
import pytest
24

35
from zulipterminal.helper import (
4-
index_messages,
6+
canonicalize_color, classify_unread_counts, index_messages, notify,
57
powerset,
6-
classify_unread_counts,
7-
canonicalize_color,
8-
notify,
98
)
10-
from typing import Any
119

1210

1311
def test_index_messages_narrow_all_messages(mocker,

tests/model/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import pytest
66

7-
from zulipterminal.model import Model, ServerConnectionFailure
87
from zulipterminal.helper import initial_index, powerset
8+
from zulipterminal.model import Model, ServerConnectionFailure
99

1010

1111
class TestModel:

tests/ui/test_ui_tools.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
import pytest
21
import datetime
3-
from collections import defaultdict, OrderedDict
2+
from collections import OrderedDict, defaultdict
3+
4+
import pytest
45
from bs4 import BeautifulSoup
6+
from urwid import AttrWrap, Columns, Padding, Text
57

6-
from zulipterminal.ui_tools.views import (
7-
MessageView,
8-
MiddleColumnView,
9-
StreamsView,
10-
TopicsView,
11-
UsersView,
12-
RightColumnView,
13-
LeftColumnView,
14-
HelpView,
15-
ModListWalker,
16-
PopUpConfirmationView,
17-
MsgInfoView,
18-
)
8+
from zulipterminal.config.keys import keys_for_command
9+
from zulipterminal.helper import powerset
1910
from zulipterminal.ui_tools.boxes import MessageBox
2011
from zulipterminal.ui_tools.buttons import (
21-
TopButton,
22-
StreamButton,
23-
UserButton,
24-
TopicButton,
12+
StreamButton, TopButton, TopicButton, UserButton,
13+
)
14+
from zulipterminal.ui_tools.views import (
15+
HelpView, LeftColumnView, MessageView, MiddleColumnView, ModListWalker,
16+
MsgInfoView, PopUpConfirmationView, RightColumnView, StreamsView,
17+
TopicsView, UsersView,
2518
)
26-
from zulipterminal.config.keys import keys_for_command
27-
from zulipterminal.helper import powerset
2819

29-
from urwid import AttrWrap, Columns, Padding, Text
3020

3121
VIEWS = "zulipterminal.ui_tools.views"
3222
TOPBUTTON = "zulipterminal.ui_tools.buttons.TopButton"

0 commit comments

Comments
 (0)