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

Proposal to use pre-commit for continuous integration #113

Merged
merged 6 commits into from Aug 31, 2023

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented Aug 31, 2023

What this PR does?

Stop using the wemake-python-styleguide which gives too many errors. And switch to pre-commit's continuous integration.

The advantage of pre-commit is that:

  1. It runs automatically when you git commit.
  2. You will not upload codes that are not aligned with some styles.

The codes are changed only in code style, the requirement of hooks.

Note: black will force you to use double quotes, it actually auto-format for you, so do not worry.

What will this PR improve?

You will see no reviewdog complaining, and pre-commit will do almost all formatting for you, and it is very fast.

How to setup pre-commit?

cd appletree
pip install pre-commit
pre-commit install

What will the configuration tell pre-commit to do?

Besides basic whitespace and large files check,

  1. black will auto-format your code, mainly about indent and line-length, and make auto-commit if necessary.
  2. docformatter will auto-format your docstring, following google convention, and make auto-commit if necessary.
  3. mypy will check the typing in your code, it is a bug finder, you still need to fix and commit them.
  4. doc8 will check the docs/*.rst and docs/*.md, it gives the warning of wrong format. Currently, there is no popular auto-formatter for .rst.
  5. flake8 will check the code-style, but in a more lite way than wemake-python-styleguide.

So there will be two pre-commit checks, one check of changed files when you git commit, and one check of all files by pre-commit CI.

How to execute pre-commit locally

When you git commit, it will automatically pre-commit run for the changed files, so actually you would not always run it manually.

If you want to check all the files, run pre-commit run --all-files. If you want to check the difference between the current branch and main, run pre-commit run --from-ref main --to-ref .. If you want to remove the color from the output, add --color never.

black and docformatter will change your code, you still need to make a commit by yourself on the changed part.

For more information, please go to https://pre-commit.com/ and https://pre-commit.ci/.

Inspired by XENONnT/straxen#1192 and XENONnT/alea#78

@coveralls
Copy link

coveralls commented Aug 31, 2023

Pull Request Test Coverage Report for Build 6038738697

  • 539 of 643 (83.83%) changed or added relevant lines in 23 files are covered.
  • 14 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.8%) to 83.865%

Changes Missing Coverage Covered Lines Changed/Added Lines %
appletree/interpolation.py 20 21 95.24%
appletree/plugin.py 8 9 88.89%
appletree/parameter.py 34 36 94.44%
appletree/init.py 6 9 66.67%
appletree/randgen.py 17 22 77.27%
appletree/plugins/nestv2.py 57 65 87.69%
appletree/config.py 47 61 77.05%
appletree/likelihood.py 76 91 83.52%
appletree/context.py 32 48 66.67%
appletree/component.py 56 74 75.68%
Files with Coverage Reduction New Missed Lines %
appletree/context.py 1 81.11%
appletree/interpolation.py 1 87.72%
appletree/likelihood.py 1 83.7%
appletree/plugins/nestv2.py 1 82.55%
appletree/randgen.py 1 84.42%
appletree/config.py 2 81.77%
appletree/component.py 3 78.91%
appletree/utils.py 4 58.06%
Totals Coverage Status
Change from base Build 6033141116: 0.8%
Covered Lines: 1918
Relevant Lines: 2287

💛 - Coveralls

@dachengx dachengx marked this pull request as ready for review August 31, 2023 14:11
@dachengx dachengx merged commit ecc08a4 into master Aug 31, 2023
7 checks passed
@dachengx dachengx deleted the use_pre-commit branch August 31, 2023 14:37
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.

None yet

2 participants