Skip to content

Commit

Permalink
Add isort to code check
Browse files Browse the repository at this point in the history
- We use the 'black' profile within the isort config to make isort
compatible with black, which is also being used in this docker
image.
  • Loading branch information
pdemp1729 committed Jan 8, 2023
1 parent c7b1ee6 commit e232864
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Expand Up @@ -9,9 +9,11 @@ COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

COPY config/.flake8 .
COPY config/.isort.cfg .
COPY entrypoint.sh /usr/local/bin

ENV DEFAULT_FLAKE8_CONFIG=${APP_ROOT}/.flake8
ENV DEFAULT_ISORT_CONFIG=${APP_ROOT}/.isort.cfg

VOLUME ${CODE_DIR}
WORKDIR ${CODE_DIR}
Expand Down
7 changes: 4 additions & 3 deletions README.md
@@ -1,10 +1,11 @@
# docker-code-quality
Docker image for python code quality
Docker image for checking python code quality

## Usage

After building the docker image using `./docker.sh build` it can be used to run [flake8](https://flake8.pycqa.org/en/6.0.0/index.html)
and [black](https://black.readthedocs.io/en/stable/index.html) (in check mode) on a codebase of your choosing.
After building the docker image using `./docker.sh build` it can be used to run [flake8](https://flake8.pycqa.org/en/6.0.0/index.html),
[black](https://black.readthedocs.io/en/stable/index.html) and [isort](https://pycqa.github.io/isort/index.html)
(in check mode) on a codebase of your choosing.
In particular, assuming you're in the directory of the code you want to check, simply run

```
Expand Down
3 changes: 3 additions & 0 deletions config/.isort.cfg
@@ -0,0 +1,3 @@
[settings]
py_version=39
profile=black
3 changes: 3 additions & 0 deletions entrypoint.sh
Expand Up @@ -3,5 +3,8 @@
echo "Running flake8..."
flake8 --config=$DEFAULT_FLAKE8_CONFIG $CODE_DIR

echo "Running isort --check"
isort --settings-file=$DEFAULT_ISORT_CONFIG --src=$CODE_DIR --check $CODE_DIR

echo "Running black --check..."
black --target-version py39 --check $CODE_DIR
1 change: 1 addition & 0 deletions requirements.txt
@@ -1,2 +1,3 @@
black==22.12.0
flake8==6.0.0
isort==5.11.1

0 comments on commit e232864

Please sign in to comment.