pypsa-eur
pypsa-eur copied to clipboard
Add pre-commit for formatting, liniting and code checking.
Closes #242 . Closes #239 .
Changes proposed in this Pull Request
Add checks, formatters and linters using pre-commit
to the repository.
Especially includes:
-
black
formatting for Python - formatting for
yaml
files -
REUSE
check for FSFE REUSE compliance
Question:
- [x] Should
pre-commit
be added to theenvironment.yaml
? --> No - [ ] Other hooks we should add?
TODOs:
- [ ] Update documentation: Add
pre-commit
encouragement (PR template + docu fromatlite
as template?) - [ ] Remove
pep8
recommendation from documentation - [ ] Connect this repository with the (http://precommit.ci/) after merging this PR
- [ ] Add this PR after the next major release as an immediate minor release (mainly formattting) to keep change transparency for
git blame
Checklist
- [x] I tested my contribution locally and it seems to work fine.
- [x] Code and workflow changes are sufficiently documented.
- [ ] Newly introduced dependencies are added to
envs/environment.yaml
andenvs/environment.docs.yaml
. - [n/a] Changes in configuration options are added in all of
config.default.yaml
,config.tutorial.yaml
, andtest/config.test1.yaml
. - [n/a] Changes in configuration options are also documented in
doc/configtables/*.csv
and line references are adjusted indoc/configuration.rst
anddoc/tutorial.rst
. - [ ] A note for the release notes
doc/release_notes.rst
is amended in the format of previous release notes.
What I also use for linopy:
Isort sorts imports of packages
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
codespell checks for spelling errors in comments and docstrings
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
types_or: [python, rst, markdown]
files: ^(scripts|doc)/
Added. isort
may be a bit controversial.
I had to exclude a regex for all CAPITAL CASE words for codespell, as it complained about the code strings THS
and BA
in scripts/build_shapes.py
Re question what to add: I like under pre-commit-hooks
- id: check-added-large-files
args: ['--maxkb=1000']
Re question what to add: I like under
pre-commit-hooks
- id: check-added-large-files args: ['--maxkb=1000']
Added, but with 2 MB as a limit. Our pictures in the documentations are sometimes larger than 1 MB.
Added, but with 2 MB as a limit. Our pictures in the documentations are sometimes larger than 1 MB.
Fair enough :1234:
This is now hot again @FabianHofmann @euronion.
Given that we already have a large number of commits in the master
I suggest we postpone it (again) until a minor release.