Skip to content

Commit

Permalink
Use black formatter
Browse files Browse the repository at this point in the history
- Adjust isort/flake8 configuration
- Format everything using black
- Add auto formatting to pre-commit hook
  • Loading branch information
Uxio0 committed Oct 15, 2021
1 parent b62df3c commit 8a300f1
Show file tree
Hide file tree
Showing 146 changed files with 5,689 additions and 3,225 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Paste here the related links for the issues on the clients/safe project if appli
# Endpoint
If applicable, description on the endpoint and the result you expect:

## URL
## URL
`GET /api/v1/safes/<address>/creation/`

## Response
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
postgres:
image: postgres:10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
Expand All @@ -37,25 +38,24 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Create virtualenv
run: |
python -m venv venv
- uses: actions/cache@v2
id: cache-pip
with:
path: ./venv
key: ${{ matrix.python-version }}-${{ hashFiles('requirements-test.txt') }}-${{ hashFiles('requirements.txt') }}
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-test.txt') }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
source venv/bin/activate
pip install -r requirements-test.txt coveralls wheel
pip install wheel
pip install -r requirements-test.txt coveralls pre-commit
env:
PIP_USE_MIRRORS: true
- name: Run pre-commit
run: pre-commit run --all-files
- name: Run tests and coverage
run: |
source venv/bin/activate
python manage.py check
python manage.py makemigrations --check --dry-run
coverage run --source=$SOURCE_FOLDER -m py.test -rxXs
env:
SOURCE_FOLDER: safe_relay_service
Expand All @@ -66,9 +66,9 @@ jobs:
REDIS_URL: redis://localhost:6379/0
CELERY_BROKER_URL: redis://localhost:6379/0
- name: Send results to coveralls
continue-on-error: true # Ignore coveralls problems
if: ${{ env.COVERALLS_REPO_TOKEN }}
run: |
source venv/bin/activate
coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand All @@ -86,16 +86,16 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy Master
if: github.ref == 'refs/heads/master'
run: bash scripts/deploy_docker_github.sh staging
run: bash scripts/deploy_docker.sh staging
env:
DOCKERHUB_PROJECT: safe-relay-service
- name: Deploy Develop
if: github.ref == 'refs/heads/develop'
run: bash scripts/deploy_docker_github.sh develop
run: bash scripts/deploy_docker.sh develop
env:
DOCKERHUB_PROJECT: safe-relay-service
- name: Deploy Tag
if: startsWith(github.ref, 'refs/tags/')
run: bash scripts/deploy_docker_github.sh ${GITHUB_REF##*/}
run: bash scripts/deploy_docker.sh ${GITHUB_REF##*/}
env:
DOCKERHUB_PROJECT: safe-relay-service
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-docstring-first
- id: check-merge-conflict
- id: debug-statements
- id: detect-private-key
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: end-of-file-fixer
types: [python]
- id: check-yaml
- id: check-added-large-files
2 changes: 1 addition & 1 deletion config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Django starts so that shared_task will use this app.
from .celery_app import app as celery_app

__all__ = ("celery_app",)
__all__ = ("celery_app",)
6 changes: 3 additions & 3 deletions config/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def on_celery_setup_logging(**kwargs):

# Patch all the code to use Celery logger (if not just logs inside tasks.py are displayed with the
# task_id and task_name). This way every log will have the context information
for _, logger in settings.LOGGING['loggers'].items():
key = 'handlers'
for _, logger in settings.LOGGING["loggers"].items():
key = "handlers"
if key in logger:
logger[key] = ['celery_console']
logger[key] = ["celery_console"]
dictConfig(settings.LOGGING)


Expand Down
Loading

0 comments on commit 8a300f1

Please sign in to comment.