Skip to content

Fixed #1199 -- Added pre-commit hooks #1198

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

Merged
merged 2 commits into from
Sep 14, 2022

Conversation

pauloxnet
Copy link
Member

As a consequence of the comments relating to the old pull request, I created a new pull request to add pre-commit.
The configuration file now has only basic hooks with the exclusion of migrations files.

@pauloxnet pauloxnet mentioned this pull request Sep 3, 2022
@pauloxnet pauloxnet closed this Sep 3, 2022
@pauloxnet pauloxnet force-pushed the feature/precommi-light branch from 1df202f to d9a6a9f Compare September 3, 2022 16:57
@pauloxnet pauloxnet reopened this Sep 3, 2022
@pauloxnet pauloxnet changed the title Added pre-commit with few hooks Fixed #1199 - Added pre-commit hooks Sep 4, 2022
@pauloxnet pauloxnet changed the title Fixed #1199 - Added pre-commit hooks Fixed #1199 -- Added pre-commit hooks Sep 4, 2022
Copy link
Member

@CuriousLearner CuriousLearner left a comment

Choose a reason for hiding this comment

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

Hi @pauloxnet

Thank you for the PR. Overall, this looks good to me.

Please find the review inline. Curious to know what are your thoughts on adding black in pre-commit hooks.

Comment on lines +15 to +18
- repo: https://github.com/pycqa/isort
rev: "5.10.1"
hooks:
- id: isort
Copy link
Member

Choose a reason for hiding this comment

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

Do you think adding black along with isort would make sense here? It would provide a consistent formatting across the project.

Please let me know your thoughts.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a specific issue to format the code base with Black so I would defer adding black in pre-commit to that scope.
#1184

Copy link
Member

Choose a reason for hiding this comment

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

Alright, that sounds good to me!

Comment on lines +410 to +420
On the first commit ``pre-commit`` will install the hooks, these are
installed in their own environments and will take a short while to
install on the first run. Subsequent checks will be significantly faster.
If the an error is found an appropriate error message will be displayed.
If the error was with ``isort`` then the tool will go ahead and fix them for
you. Review the changes and re-stage for commit if you are happy with
them.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
On the first commit ``pre-commit`` will install the hooks, these are
installed in their own environments and will take a short while to
install on the first run. Subsequent checks will be significantly faster.
If the an error is found an appropriate error message will be displayed.
If the error was with ``isort`` then the tool will go ahead and fix them for
you. Review the changes and re-stage for commit if you are happy with
them.
On the first commit ``pre-commit`` will install the hooks, these are
installed in their environments and will take a short while to
install on the first run. Subsequent checks will be significantly faster.
If an error is found an appropriate error message will be displayed.
If the error was with ``isort`` then the tool will go ahead and fix them for
you. Review the changes and re-stage for commit if you are happy with
them.

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied this paragraph from the Django code, so I'd rather it stay aligned here too, or at most I'd make your changes in both repositories.
https://github.com/django/django/blob/main/docs/internals/contributing/writing-code/coding-style.txt#L9

Copy link
Member

Choose a reason for hiding this comment

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

Okay. @carltongibson what are your thoughts?

@pauloxnet pauloxnet force-pushed the feature/precommi-light branch from 97baf98 to a76fca4 Compare September 14, 2022 16:16
@pauloxnet
Copy link
Member Author

I rebased this PR and solved the conflicts. I think it's ready to be merged.

@camilonova camilonova merged commit 52d83df into django:main Sep 14, 2022
sabderemane pushed a commit to sabderemane/djangoproject.com that referenced this pull request Sep 24, 2022
* Added pre-commit with a few hooks

* Add pre-commit instructions in README
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.

3 participants