|
| 1 | +--- |
| 2 | +# pre-commit is a tool to perform a predefined set of tasks manually and/or |
| 3 | +# automatically before git commits are made. |
| 4 | +# |
| 5 | +# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level |
| 6 | +# |
| 7 | +# Common tasks |
| 8 | +# |
| 9 | +# - Run on all files: pre-commit run --all-files |
| 10 | +# - Register git hooks: pre-commit install --install-hooks |
| 11 | +# |
| 12 | +# See https://pre-commit.com for more information |
| 13 | +# See https://pre-commit.com/hooks.html for more hooks |
| 14 | +repos: |
| 15 | + # Autoupdate: Python code |
| 16 | + - repo: https://github.com/asottile/pyupgrade |
| 17 | + rev: v2.34.0 |
| 18 | + hooks: |
| 19 | + - id: pyupgrade |
| 20 | + args: [--py39-plus] |
| 21 | + |
| 22 | + # Automatically sort python imports |
| 23 | + - repo: https://github.com/pycqa/isort |
| 24 | + rev: 5.10.1 |
| 25 | + hooks: |
| 26 | + - id: isort |
| 27 | + args: [--profile, black] |
| 28 | + |
| 29 | + # Autoformat: Python code |
| 30 | + - repo: https://github.com/psf/black |
| 31 | + rev: 22.6.0 |
| 32 | + hooks: |
| 33 | + - id: black |
| 34 | + args: [--target-version=py39] |
| 35 | + |
| 36 | + # Check python code static typing |
| 37 | + - repo: https://github.com/pre-commit/mirrors-mypy |
| 38 | + rev: v0.961 |
| 39 | + hooks: |
| 40 | + - id: mypy |
| 41 | + args: [--config, ./mypy.ini] |
| 42 | + additional_dependencies: |
| 43 | + ["numpy", "pytest", "requests", "types-requests", "types-tabulate"] |
| 44 | + # Unfortunately, `pre-commit` only runs on changed files |
| 45 | + # This doesn't work well with `mypy --follow-imports error` |
| 46 | + # See: https://github.com/pre-commit/mirrors-mypy/issues/34#issuecomment-1062160321 |
| 47 | + # |
| 48 | + # To work around this we run `mypy` only in manual mode |
| 49 | + # So it won't run as part of `git commit` command |
| 50 | + # But it will still be run as part of `pre-commit` workflow and give expected results |
| 51 | + stages: [manual] |
| 52 | + |
| 53 | + # Autoformat: YAML, JSON, Markdown, etc. |
| 54 | + - repo: https://github.com/pre-commit/mirrors-prettier |
| 55 | + rev: v2.7.1 |
| 56 | + hooks: |
| 57 | + - id: prettier |
| 58 | + |
| 59 | + # `pre-commit sample-config` default hooks |
| 60 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 61 | + rev: v4.3.0 |
| 62 | + hooks: |
| 63 | + - id: check-added-large-files |
| 64 | + - id: end-of-file-fixer |
| 65 | + - id: trailing-whitespace |
| 66 | + |
| 67 | + # Lint: Python |
| 68 | + - repo: https://github.com/PyCQA/flake8 |
| 69 | + rev: 4.0.1 |
| 70 | + hooks: |
| 71 | + - id: flake8 |
| 72 | + |
| 73 | + # Lint: Markdown |
| 74 | + - repo: https://github.com/igorshubovych/markdownlint-cli |
| 75 | + rev: v0.31.1 |
| 76 | + hooks: |
| 77 | + - id: markdownlint |
| 78 | + args: ["--fix"] |
0 commit comments