Skip to content

Commit a246043

Browse files
authored
Merge pull request #111 from HazyResearch/autoformat
Add utilities for autoformatting
2 parents 976c9e9 + c7ddc03 commit a246043

File tree

6 files changed

+96
-0
lines changed

6 files changed

+96
-0
lines changed

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is our code-style check. We currently allow the following exceptions:
2+
# - E731: do not assign a lambda expression, use a def
3+
# - W503: line break before binary operator
4+
# - E741: do not use variables named 'l', 'O', or 'I'
5+
# - E203: whitespace before ':'
6+
[flake8]
7+
count = True
8+
max-line-length = 100
9+
statistics = True
10+
ignore = E731,W503,E741,E203

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
16+
Linting:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: ['3.8', '3.9', '3.10']
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- uses: actions/cache@v2
30+
with:
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip
33+
34+
- name: Install Dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements-dev.txt
38+
39+
- name: Lint with isort, black, docformatter, flake8
40+
run: |
41+
make lint

.isort.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[settings]
2+
multi_line_output = 3
3+
include_trailing_comma = True
4+
force_grid_wrap = 0
5+
use_parentheses = True
6+
ensure_newline_before_comments = True
7+
line_length = 100

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/timothycrosley/isort
3+
rev: 5.12.0
4+
hooks:
5+
- id: isort
6+
- repo: https://github.com/psf/black
7+
rev: 23.7.0
8+
hooks:
9+
- id: black
10+
language_version: python3
11+
additional_dependencies: ['click==8.0.4']
12+
exclude: 'scratch/.*'
13+
14+
- repo: https://github.com/pycqa/flake8
15+
rev: 6.0.0
16+
hooks:
17+
- id: flake8
18+
exclude: 'scratch/.*'

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
autoformat:
2+
black src/ checkpoints/ models/
3+
isort --atomic src/ checkpoints/ models/
4+
docformatter --in-place --recursive src checkpoints models
5+
6+
lint:
7+
isort -c src/ checkpoints/ models/
8+
black src/ checkpoints/ models/ --check
9+
flake8 src/ checkpoints/ models/
10+
11+
dev:
12+
pip install -r requirements-dev.txt

requirements-dev.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
coverage
2+
flake8
3+
isort
4+
black==23.7.0 # pin black because changes can result in large diffs in PRs
5+
flake8-bugbear
6+
flake8-comprehensions
7+
pre-commit>=2.9.3
8+
docformatter

0 commit comments

Comments
 (0)