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

Configure Precommit hooks with black and isort #1416

Merged
merged 6 commits into from
Jan 31, 2024
Merged

Conversation

vrdmr
Copy link
Member

@vrdmr vrdmr commented Jan 31, 2024

Description

This change is to introduce precommit hooks to ensure same dev setup across the team.

  1. Added a new dev requirement - precommit-hooks
  2. Added a new config file .pre-commit-config.yaml and configured it with black and isort for now.
  3. Installing it first time on your box once it is setup
azfuncpyworker on  vameru/precommit-hook [$!] via venv311Arm64 via 🐍 system took 15s 
➜ pre-commit install
[WARNING] The 'rev' field of repo 'https://github.com/psf/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
pre-commit installed at .git/hooks/pre-commit
  1. When you do a commit, black is run automatically and it there are any updates, it'll change it and fail the commit to make you add it explicitly.
azfuncpyworker on  vameru/precommit-hook [$+] via venv311Arm64 via 🐍 system 
➜ git commit -m "test"
black....................................................................Failed
- hook id: black
- files were modified by this hook

reformatted azure_functions_worker/constants.py

All done! ✨ 🍰 ✨
1 file reformatted.
  1. If you don't have any relevant files changed, the configurations won't run
azfuncpyworker on  vameru/precommit-hook [$+] via venv311Arm64 via 🐍 system 
➜ git commit -m "Updating flake8 limits and add isort to precommit"
[INFO] Initializing environment for https://github.com/PyCQA/isort.
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black................................................(no files to check)Skipped
isort................................................(no files to check)Skipped
[vameru/precommit-hook 194ff51] Updating flake8 limits and add isort to precommit
 2 files changed, 6 insertions(+), 1 deletion(-)

The current black state is the following and will send another PR for this.

azfuncpyworker on  vameru/precommit-hook [$] via venv311Arm64 via 🐍 system 
➜ pre-commit run --all-files
black....................................................................Failed
- hook id: black
- exit code: 123
- files were modified by this hook

reformatted azure_functions_worker/__main__.py
reformatted azure_functions_worker/bindings/__init__.py
...
reformatted tests/unittests/broken_functions/return_param_in/main.py
error: cannot format tests/unittests/broken_functions/syntax_error/main.py: Cannot parse: 6:15:     1 /  # noqa
reformatted tests/unittests/broken_functions/wrong_param_dir/main.py
...
reformatted tests/unittests/test_utilities.py
reformatted tests/utils/testutils.py

Oh no! 💥 💔 💥
306 files reformatted, 72 files left unchanged, 1 file failed to reformat.

Fixes #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (535b3d9) 85.31% compared to head (224a9b9) 85.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1416      +/-   ##
==========================================
+ Coverage   85.31%   85.87%   +0.55%     
==========================================
  Files          35       35              
  Lines        1968     1968              
  Branches      370      370              
==========================================
+ Hits         1679     1690      +11     
+ Misses        216      209       -7     
+ Partials       73       69       -4     
Flag Coverage Δ
unittests 85.82% <ø> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vrdmr vrdmr merged commit c0a2c3c into dev Jan 31, 2024
31 of 51 checks passed
@vrdmr vrdmr deleted the vameru/precommit-hook branch January 31, 2024 22:16
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