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

Adding pre-commit #338

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Adding pre-commit #338

wants to merge 1 commit into from

Conversation

4383
Copy link
Contributor

@4383 4383 commented Sep 3, 2020

The rationale behind these changes is to catch linter errors (pep8) automatically before developers submit their changes and pull-requests.

These changes will help us become proactive with the apply of our coding rules (pep8, etc...) and avoid back and forth with patches and reviews.

In other words these changes could help us to reduce our CI usages and possibly also help us to reduce the amount (of pending) reviews by catching early issues on the developer side.

Note that pre-commit is optional and people who don't want to use it don't need to do something.

With these changes tox is plugged on pre-commit to run flake8 checks, this approach allow us to centralize things and avoid to duplicate how this kind of test is executed.

Introduced changes:

  • pre-commit config and rules
  • Flake8 is covered in the pre-commit hooks.
  • Applying fixes for pre-commit compliance in all code.

Also it is worth to note that commit hash will be used instead of version tags
in pre-commit to prevend arbitrary code from running in developer's machines.

pre-commit will be used to:

  • trailing whitespace;
  • Replaces or checks mixed line ending (mixed-line-ending);
  • Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
  • Checks that non-binary executables have a proper
    shebang (check-executables-have-shebangs);
  • Check for files that contain merge conflict strings (check-merge-conflict);
  • Check for debugger imports and py37+ breakpoint()
    calls in python source (debug-statements);
  • Attempts to load all yaml files to verify syntax (check-yaml);
  • Run flake8 checks (flake8) (local)

Also these changes can be used automatically by using:

$ pip install pre-commit
$ pre-commit install

With the previous commands checks will be passed at each commit by using git-hooks' mechanisms.

For further details about tests please refer to: https://github.com/pre-commit/pre-commit-hooks

Also note that the changes on docs/make.bat are simply file permissions to render this file as an executable file.

Introduced changes:
- pre-commit config and rules
- Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.

Also it is worth to note that commit hash will be used instead of version tags
in pre-commit to prevend arbitrary code from running in developer's machines.

pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
- Checks that non-binary executables have a proper
  shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
  calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)

For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks
@thedrow
Copy link
Member

thedrow commented Sep 8, 2020

Thank you.

I'll review this after I finish releasing Celery 5.

@thedrow thedrow self-assigned this Sep 8, 2020
@4383
Copy link
Contributor Author

4383 commented Sep 8, 2020

@thedrow thanks

@4383
Copy link
Contributor Author

4383 commented Jul 6, 2021

Hello @thedrow,

An update about these changes?

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think only the merge conflicts should be fixed here

- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://gitlab.com/pycqa/flake8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it available in github as well?

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

3 participants