Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit for formatting, liniting and code checking. #302

Closed
wants to merge 20 commits into from

Conversation

euronion
Copy link
Contributor

@euronion euronion commented Jan 11, 2022

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:

  • Should pre-commit be added to the environment.yaml? --> No
  • Other hooks we should add?

TODOs:

  • Update documentation: Add pre-commit encouragement (PR template + docu from atlite 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

  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and envs/environment.docs.yaml.
  • [n/a] Changes in configuration options are added in all of config.default.yaml, config.tutorial.yaml, and test/config.test1.yaml.
  • [n/a] Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes.

Remove strictness for yamllint to prevent "Failed" precommit status on too long lines.

Remove width restriction on yamlfmt to prevent breaking of long lists which are then indented "inconsistently" according to yamllint.

(Arbitrary changes which seem reasonable at the moment; mainly caused by inconsistencies between pyaaml and ruamel.yaml).
Line length according to black (80 characters + <=10%).
Option "braces = disable" removes validity of "{}" of entries in yaml file, but those are necessary for the configuration-> manual ignore required.
(Run `pre-commit run --all-files` )
@euronion euronion added this to the Release 0.5 milestone Jan 11, 2022
@euronion euronion mentioned this pull request Jan 11, 2022
6 tasks
@FabianHofmann
Copy link
Contributor

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)/

@euronion
Copy link
Contributor Author

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

@fneum
Copy link
Member

fneum commented Jan 13, 2022

Re question what to add: I like under pre-commit-hooks

  - id: check-added-large-files
    args: ['--maxkb=1000']

@euronion
Copy link
Contributor Author

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.

@fneum
Copy link
Member

fneum commented Jan 13, 2022

Added, but with 2 MB as a limit. Our pictures in the documentations are sometimes larger than 1 MB.

Fair enough 🔢

@fneum fneum modified the milestones: Release 0.5, Release 0.5.1 Feb 1, 2022
@fneum
Copy link
Member

fneum commented Jul 27, 2022

This is now hot again @FabianHofmann @euronion.

@euronion
Copy link
Contributor Author

Given that we already have a large number of commits in the master I suggest we postpone it (again) until a minor release.

@FabianHofmann FabianHofmann mentioned this pull request Sep 16, 2022
3 tasks
fneum added a commit that referenced this pull request Mar 6, 2023
add min part load for FT and methanolisation via p_min_pu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement support GitHub actions.
3 participants