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

Feature/add pre commit hook for linting #217

Merged
merged 9 commits into from
Nov 13, 2024

Conversation

4lm
Copy link

@4lm 4lm commented Nov 8, 2022

This PR is based on unmerged PR #197.

Closes #215.

@Bachibouzouk, please review this PR and merge on approval. But first, PR #197 needs to be fixed as spoken by you and merged because this PR depends on it.

This PR uses pre-commit for installing and managing Git hooks.

Initial installation:

  • activate your local Python environment
  • install pre-commit: pip install (app/)requirements.txt
  • install Git hooks: pre-commit install

The config can be found in .pre-commit-config.yaml in the root folder.

Hooks run before every commit.

Run changed files manually:

  • pre-commit

Run all files manually (recommended after installing a new hook):

  • pre-commit

Please note: I configured that hooks shall fail fast. This can result in running the commit (or pre-commit) multiple times. If we realize that this behavior is different from what we want to see, we can change it in the config in the future.

@4lm 4lm requested a review from Bachibouzouk November 8, 2022 16:08
@@ -2,6 +2,7 @@

psycopg2-binary==2.9.3

black==19.3b

Choose a reason for hiding this comment

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

Changing black version now will make a huge black diff

Copy link
Author

Choose a reason for hiding this comment

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

Ok, as we said in #215. Fine with me, if you merge this PR after the workshop :)

@paulapreuss
Copy link

@Bachibouzouk what is the situation with this PR / issue? I think it would be nice to get the pre-commit hooks set up once before starting back up with development, then it is out of the way :)

@Bachibouzouk
Copy link

Thanks @paulapreuss for taclking this, I think it make sense to tackle precommit at this stage

@Bachibouzouk
Copy link

I think this PR needs rebase

@paulapreuss paulapreuss force-pushed the feature/add-pre-commit-hook-for-linting branch 4 times, most recently from 7685297 to 05111db Compare November 11, 2024 14:34
@paulapreuss
Copy link

paulapreuss commented Nov 11, 2024

@Bachibouzouk I rebased this on main, added some hooks that were not listed but we are using in CP Nigeria and updated the black version to the most current one (24.8). Feel free to have a look and let me know if this is good to go or you would like to handle anything differently.

@paulapreuss paulapreuss force-pushed the feature/add-pre-commit-hook-for-linting branch from ce85177 to de0c562 Compare November 13, 2024 12:26
@@ -1,18 +1,21 @@
django-extensions==3.0.9
Django==4.2.4

Choose a reason for hiding this comment

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

Here we might even take the opportunity to upgrade to the latest Django version, I would rather do this in a separate PR and thus only rename the file without changing the dependencies (keeping the changes though)

@@ -5,4 +5,5 @@ python manage.py migrate && \
python manage.py update_assettype && \
python manage.py loaddata 'fixtures/multivector_fixture.json' && \
echo yes | python manage.py collectstatic && \
pre-commit install && \

Choose a reason for hiding this comment

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

Is it added to the dependencies the developpers need to install in the README steps? If not can you add a it there?

Choose a reason for hiding this comment

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

Good catch, I did forget to update the readme.

@Bachibouzouk
Copy link

I rebased this on main

@paulapreuss - are you sure? When I checked out the branch the history did not build on top of main rather on top of fix/storage-sub-components-name. I did rebase locally onto main and there were no conflicts. Maybe your version of main was outdated?

@paulapreuss
Copy link

I rebased this on main

@paulapreuss - are you sure? When I checked out the branch the history did not build on top of main rather on top of fix/storage-sub-components-name. I did rebase locally onto main and there were no conflicts. Maybe your version of main was outdated?

You're right, apparently I had not pulled the most recent changes. I'll rebase it again.

@paulapreuss paulapreuss force-pushed the feature/add-pre-commit-hook-for-linting branch from de0c562 to 1c045f4 Compare November 13, 2024 14:36
Copy link

@Bachibouzouk Bachibouzouk left a comment

Choose a reason for hiding this comment

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

Thanks @4lm for initiating and @paulapreuss for updating it :)

@paulapreuss paulapreuss merged commit 829ab80 into main Nov 13, 2024
2 checks passed
@paulapreuss paulapreuss deleted the feature/add-pre-commit-hook-for-linting branch November 13, 2024 15:00
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.

Add pre-commit hook for linting
3 participants