Skip to content

Commit 840827d

Browse files
authored
Add isort to our linting toolkit (#14)
This adds isort to our CI pipeline, which checks the order and format of imports. Developers can use isort to automatically do import sorting for them, and a section on this is now in the README. We configure isort to use the "black" profile, which should prevent any disagreements on import formatting between the two tools. However, in CI, we always run black last to give it the final say on formatting.
1 parent 7e99513 commit 840827d

15 files changed

Lines changed: 132 additions & 87 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- run: "curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
2626
| python3 - --version 1.1.0"
2727
- run: poetry install --no-root
28+
- run: poetry run isort --check .
2829
- run: poetry run black --check .
2930
- run: poetry run mypy -p "brainframe.cli"
3031
upload_to_pypi:

README.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,20 @@ using the ``compose`` command, which can be run from any directory.
4444
For more information, take a look at the `Getting Started guide`_.
4545

4646
.. _`Getting Started guide`: https://aotu.ai/docs/getting_started/
47+
48+
Contributing
49+
------------
50+
51+
We happily take community contributions! If there's something you'd like to
52+
work on, but you're not sure how to start, feel free to create an issue on
53+
Github and we'll try to point you in the right direction.
54+
55+
We use a couple formatting tools to keep our code style consistent. If you get
56+
any CI failures, you can run the following commands to automatically format
57+
your code to fit our guidelines:
58+
59+
.. code-block:: bash
60+
61+
poetry run isort .
62+
poetry run black .
63+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .backup import backup
22
from .compose import compose
3+
from .info import info
34
from .install import install
45
from .update import update
5-
from .info import info
66
from .utils import by_name

brainframe/cli/commands/backup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
from pathlib import Path
55

66
import i18n
7-
87
from brainframe.cli import (
9-
print_utils,
10-
docker_compose,
11-
os_utils,
128
dependencies,
9+
docker_compose,
1310
env_vars,
11+
os_utils,
12+
print_utils,
1413
)
15-
from .utils import subcommand_parse_args, command
14+
15+
from .utils import command, subcommand_parse_args
1616

1717
BACKUP_DIR_FORMAT = "%Y-%m-%d_%H-%M-%S"
1818

brainframe/cli/commands/compose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22

33
import i18n
4-
54
from brainframe.cli import docker_compose, env_vars, os_utils, print_utils
5+
66
from .utils import command
77

88

brainframe/cli/commands/info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from argparse import ArgumentParser
22

33
import i18n
4+
from brainframe.cli import docker_compose, env_vars, print_utils
45

5-
from brainframe.cli import env_vars, print_utils, docker_compose
6-
from .utils import subcommand_parse_args, command
6+
from .utils import command, subcommand_parse_args
77

88

99
@command("info")

brainframe/cli/commands/install.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
from pathlib import Path
33

44
import i18n
5-
65
from brainframe.cli import (
7-
print_utils,
6+
dependencies,
87
docker_compose,
98
env_vars,
109
os_utils,
11-
dependencies,
10+
print_utils,
1211
)
13-
from .utils import subcommand_parse_args, command
12+
13+
from .utils import command, subcommand_parse_args
1414

1515

1616
@command("install")

brainframe/cli/commands/update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from argparse import ArgumentParser
2-
from packaging import version
32

43
import i18n
4+
from brainframe.cli import docker_compose, env_vars, print_utils
5+
from packaging import version
56

6-
from brainframe.cli import print_utils, docker_compose, env_vars
7-
from .utils import subcommand_parse_args, command
7+
from .utils import command, subcommand_parse_args
88

99

1010
@command("update")

brainframe/cli/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import shutil
22

3-
from . import print_utils, os_utils
3+
from . import os_utils, print_utils
44

55

66
class Dependency:

brainframe/cli/docker_compose.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import os
12
import subprocess
23
from pathlib import Path
3-
from typing import List, Tuple, cast, TextIO
4-
import yaml
4+
from typing import List, TextIO, Tuple, cast
5+
56
import i18n
6-
import os
7+
import yaml
78

8-
from . import os_utils, print_utils, env_vars
9+
from . import env_vars, os_utils, print_utils
910

1011
# The URL to the docker-compose.yml
1112
BRAINFRAME_DOCKER_COMPOSE_URL = "https://{subdomain}aotu.ai/releases/brainframe/{version}/docker-compose.yml"

0 commit comments

Comments
 (0)