Skip to content

Commit

Permalink
feat(code): Add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mlissner committed Mar 23, 2022
1 parent 183d15d commit b1df27b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Black Code Formatter
uses: psf/black@stable

- uses: pre-commit/[email protected]
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: migrations
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: [--remove]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/ikamensh/flynt/
rev: '0.76'
hooks:
- id: flynt
args: [--line-length=79, --transform-concats]

- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)

#
# Tried and Failed
#
# 1. I tried doing mypy too, but it was a mess because it runs in its own
# isolated environment, that lacks all our dependencies.
# 2. We might want flake8 someday. It's easy to turn on, but it's so noisy on
# our current code that it'd take some fine-tuning to get it right.
# 3. semgrep was too slow and had to be moved to a github action.
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,17 @@
line-length = 79
include = '''.*\.pyi?$'''

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 79
skip_glob = "*/migrations/*.py"

[tool.pylint.messages_control]
disable = "C0330, C0326"

[tool.pylint.format]
max-line-length = "79"
4 changes: 3 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

# For uploading things to pypi
twine
# For making distributions
wheel

# For cleaning the code
pre-commit

0 comments on commit b1df27b

Please sign in to comment.