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:
blackformatting for Python- formatting for
yamlfiles REUSEcheck for FSFE REUSE compliance
Question:
- [x] Should
pre-commitbe added to theenvironment.yaml? --> No - [ ] Other hooks we should add?
TODOs:
- [ ] Update documentation: Add
pre-commitencouragement (PR template + docu fromatliteas template?) - [ ] Remove
pep8recommendation 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.yamlandenvs/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/*.csvand line references are adjusted indoc/configuration.rstanddoc/tutorial.rst. - [ ] A note for the release notes
doc/release_notes.rstis 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.