Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities for autoformatting #111

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is our code-style check. We currently allow the following exceptions:
# - E731: do not assign a lambda expression, use a def
# - W503: line break before binary operator
# - E741: do not use variables named 'l', 'O', or 'I'
# - E203: whitespace before ':'
[flake8]
count = True
max-line-length = 100
statistics = True
ignore = E731,W503,E741,E203
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:

Linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Lint with isort, black, docformatter, flake8
run: |
make lint
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 100
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3
additional_dependencies: ['click==8.0.4']
exclude: 'scratch/.*'

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
exclude: 'scratch/.*'
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
autoformat:
black src/ checkpoints/ models/
isort --atomic src/ checkpoints/ models/
docformatter --in-place --recursive src checkpoints models

lint:
isort -c src/ checkpoints/ models/
black src/ checkpoints/ models/ --check
flake8 src/ checkpoints/ models/

dev:
pip install -r requirements-dev.txt
8 changes: 8 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage
flake8
isort
black==23.7.0 # pin black because changes can result in large diffs in PRs
flake8-bugbear
flake8-comprehensions
pre-commit>=2.9.3
docformatter