pypsa-eur/.pre-commit-config.yaml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.4 KiB
YAML
Raw Normal View History

# SPDX-FileCopyrightText: : 2022 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: CC0-1.0
2022-09-08 08:46:00 +00:00
exclude: "^LICENSES"
repos:
2022-09-13 12:43:53 +00:00
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
2022-09-13 12:43:53 +00:00
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-added-large-files
args: ["--maxkb=2000"]
2022-09-08 08:46:00 +00:00
# Sort package imports alphabetically
2022-09-13 12:43:53 +00:00
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
2022-09-13 12:43:53 +00:00
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
2022-09-08 08:46:00 +00:00
# Convert relative imports to absolute imports
2022-09-13 12:43:53 +00:00
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
2022-09-08 08:46:00 +00:00
# Find common spelling mistakes in comments and docstrings
2022-09-13 12:43:53 +00:00
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
2022-09-13 12:43:53 +00:00
hooks:
- id: codespell
args: ['--ignore-regex="(\b[A-Z]+\b)"', '--ignore-words-list=fom'] # Ignore capital case words, e.g. country codes
2022-09-13 12:43:53 +00:00
types_or: [python, rst, markdown]
files: ^(scripts|doc)/
2022-09-08 08:46:00 +00:00
# Make docstrings PEP 257 compliant
- repo: https://github.com/PyCQA/docformatter
rev: v1.6.0.rc1
2022-09-13 12:43:53 +00:00
hooks:
- id: docformatter
args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
2022-09-08 08:46:00 +00:00
2022-09-13 12:43:53 +00:00
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
2022-09-13 12:43:53 +00:00
hooks:
- id: blackdoc
2022-09-08 08:46:00 +00:00
# Formatting with "black" coding style
2022-09-13 12:43:53 +00:00
- repo: https://github.com/psf/black
rev: 22.12.0
2022-09-13 12:43:53 +00:00
hooks:
2022-09-08 08:46:00 +00:00
# Format Python files
2022-09-13 12:43:53 +00:00
- id: black
2022-09-08 08:46:00 +00:00
# Format Jupyter Python notebooks
2022-09-13 12:43:53 +00:00
- id: black-jupyter
2022-09-08 08:46:00 +00:00
# Remove output from Jupyter notebooks
2022-09-13 12:43:53 +00:00
- repo: https://github.com/aflc/pre-commit-jupyter
rev: v1.2.1
hooks:
- id: jupyter-notebook-cleanup
args: ["--remove-kernel-metadata"]
2022-09-08 08:46:00 +00:00
# Do YAML formatting (before the linter checks it for misses)
2022-09-13 12:43:53 +00:00
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.6.0
2022-09-13 12:43:53 +00:00
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, "2", --preserve-quotes]
2022-09-08 08:46:00 +00:00
# Format Snakemake rule / workflow files
2022-09-13 12:43:53 +00:00
- repo: https://github.com/snakemake/snakefmt
rev: v0.8.0
2022-09-13 12:43:53 +00:00
hooks:
- id: snakefmt
2022-09-08 08:46:00 +00:00
# For cleaning jupyter notebooks
2022-09-13 12:43:53 +00:00
- repo: https://github.com/aflc/pre-commit-jupyter
rev: v1.2.1
hooks:
- id: jupyter-notebook-cleanup
exclude: examples/solve-on-remote.ipynb
# Check for FSFE REUSE compliance (licensing)
- repo: https://github.com/fsfe/reuse-tool
rev: v1.1.0
hooks:
- id: reuse