Skip to content

Commit

Permalink
ci: add .pre-commit-config.yaml and .flake8 config
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed May 28, 2022
1 parent 330dd64 commit 356dfa2
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# flake8 is a Python linting tool run by pre-commit as declared by our
# pre-commit-config.yaml file.
#
# This configuration is compatible with the autoformatter tool black, and
# further relaxed to not bug us with too small details.
#
# flake8 configuration reference:
# https://flake8.pycqa.org/en/latest/user/configuration.html
#
[flake8]
max-line-length = 88
extend-ignore = C, E, W

# Adjustments to linting
builtins = c
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Run on all files: pre-commit run --all-files
# - Register git hooks: pre-commit install --install-hooks
#
repos:
# Autoformat: Python code, syntax patterns are modernized
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
hooks:
- id: pyupgrade
args:
- --py37-plus

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args:
# --target-version should be all supported versions
- --target-version=py37
- --target-version=py38
- --target-version=py39
- --target-version=py310

# Autoformat: Python code
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args:
- --profile=black

# Autoformat: js, html, markdown, yaml, json
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
hooks:
- id: prettier
exclude_types:
# These are excluded initially as pre-commit was added but can
# absolutely be enabled later. If so, we should consider having a
# separate run of pre-commit where we configure a line spacing of 4
# for these file formats.
- html
- javascript
- css

# Misc autoformatting and linting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: end-of-file-fixer
exclude_types: [svg, css, json]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
# These files have requirements.in files associated with them, and are
# generated by pip-compile.
#
exclude: >
images/minesweeper/requirements.txt|
images/federation-redirect/requirements.txt
# Lint: Python code
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
hooks:
- id: flake8

0 comments on commit 356dfa2

Please sign in to comment.