add precommit-yaml config
This commit is contained in:
parent
ef2633ae05
commit
02725e00f0
86
.pre-commit-config.yaml
Normal file
86
.pre-commit-config.yaml
Normal file
@ -0,0 +1,86 @@
|
||||
exclude: "^LICENSES"
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
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"]
|
||||
|
||||
# Sort package imports alphabetically
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
args: ["--profile", "black", "--filter-files"]
|
||||
|
||||
# Convert relative imports to absolute imports
|
||||
- repo: https://github.com/MarcoGorelli/absolufy-imports
|
||||
rev: v0.3.1
|
||||
hooks:
|
||||
- id: absolufy-imports
|
||||
|
||||
# Find common spelling mistakes in comments and docstrings
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.1
|
||||
hooks:
|
||||
- id: codespell
|
||||
args: [
|
||||
'--ignore-regex="(\b[A-Z]+\b)"',
|
||||
] # Ignore capital case words, e.g. country codes
|
||||
types_or: [python, rst, markdown]
|
||||
files: ^(scripts|doc)/
|
||||
|
||||
# Make docstrings PEP 257 compliant
|
||||
- repo: https://github.com/myint/docformatter
|
||||
rev: v1.5.0
|
||||
hooks:
|
||||
- id: docformatter
|
||||
args:
|
||||
["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
|
||||
|
||||
- repo: https://github.com/keewis/blackdoc
|
||||
rev: v0.3.5
|
||||
hooks:
|
||||
- id: blackdoc
|
||||
|
||||
# Formatting with "black" coding style
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.8.0
|
||||
hooks:
|
||||
# Format Python files
|
||||
- id: black
|
||||
# Format Jupyter Python notebooks
|
||||
- id: black-jupyter
|
||||
|
||||
# Remove output from Jupyter notebooks
|
||||
- repo: https://github.com/aflc/pre-commit-jupyter
|
||||
rev: v1.2.1
|
||||
hooks:
|
||||
- id: jupyter-notebook-cleanup
|
||||
args: ["--remove-kernel-metadata"]
|
||||
|
||||
# Do YAML formatting (before the linter checks it for misses)
|
||||
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: pretty-format-yaml
|
||||
args: [--autofix, --indent, "2", --preserve-quotes]
|
||||
|
||||
# Format Snakemake rule / workflow files
|
||||
- repo: https://github.com/snakemake/snakefmt
|
||||
rev: 0.4.4
|
||||
hooks:
|
||||
- id: snakefmt
|
||||
|
||||
# For cleaning jupyter notebooks
|
||||
- repo: https://github.com/aflc/pre-commit-jupyter
|
||||
rev: v1.2.1
|
||||
hooks:
|
||||
- id: jupyter-notebook-cleanup
|
||||
exclude: examples/solve-on-remote.ipynb
|
@ -16,7 +16,17 @@ to our `GitHub repository <https://github.com/PyPSA/PyPSA-Eur>`_.
|
||||
* If you start working on a feature in the code, let us know by opening an issue or a draft pull request.
|
||||
This helps all of us to keep an overview on what is being done and helps to avoid a situation where we
|
||||
are doing the same work twice in parallel.
|
||||
* We encourage you to use the `PEP 8 coding style <https://www.python.org/dev/peps/pep-0008/>`_.
|
||||
|
||||
For linting, formatting and checking your code contributions
|
||||
against our guidelines (e.g. we use `Black <https://github.com/psf/black>`_ as code style
|
||||
use `pre-commit <https://pre-commit.com/index.html>`_:
|
||||
|
||||
1. Installation ``conda install -c conda-forge pre-commit`` or ``pip install pre-commit``
|
||||
2. Usage:
|
||||
* To automatically activate ``pre-commit`` on every ``git commit``: Run ``pre-commit install``
|
||||
* To manually run it: ``pre-commit run --all``
|
||||
|
||||
Note that installing `pre-commit` locally is not strictly necessary. If you create a Pull Request the `pre-commit CI` will be triggered automatically and take care of the checks.
|
||||
|
||||
For all code contributions we follow the four eyes principle (two person principle), i.e. all suggested code
|
||||
including our own are reviewed by a second person before they are incoporated into our repository.
|
||||
|
Loading…
Reference in New Issue
Block a user