Skip to content

Introduce pre-commit to simplify contributions #866

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 3 commits into from
Dec 5, 2020

Conversation

sliverc
Copy link
Member

@sliverc sliverc commented Nov 22, 2020

Fixes #861

Description of the Change

Add pre-commit for editor independent checking of linting and formatting of code before committing changes to git.

I have added a pre-commit configuration which uses the locally resp. in the virtual environment installed version of flake8, isort and black. pre-commit also has a way of handling the installation of such tools. However PyUp cannot update those version references and we might end up with different version in pre-commit and requirements.txt which we should avoid.

The only down side to run tools locally is that a virtual env needs to be activated before committing. This needs to be the case anyway to run tests.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@sliverc sliverc requested a review from n2ygk November 22, 2020 21:08
@codecov
Copy link

codecov bot commented Nov 22, 2020

Codecov Report

Merging #866 (80fa5f4) into master (c356806) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #866   +/-   ##
=======================================
  Coverage   97.74%   97.74%           
=======================================
  Files          60       60           
  Lines        3319     3319           
=======================================
  Hits         3244     3244           
  Misses         75       75           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c356806...80fa5f4. Read the comment docs.

Copy link
Contributor

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

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

Consider adding something like the following to tox.ini as a mean of making it easy for someone to set up the venv:

[testenv:devenv]
envdir = env
basepython = python3.6
usedevelop = True
deps =
    -rrequirements.txt
commands =
    /usr/bin/printf '\n\033[0;31m  dont forget to source env/bin/activate\033[0m\n'

@sliverc
Copy link
Member Author

sliverc commented Dec 3, 2020

@n2ygk Actually to run tox there is no need to create a virtual env as tox manages this for the user. DRF also suggests to install tox globally. It is a good reminder though that I missed out on documenting how to use tox. I have integrated it now the same way as DRF documented it.

@sliverc sliverc requested a review from n2ygk December 5, 2020 17:44

To run tests clone the repository, and then:

# Setup the virtual environment
Copy link
Contributor

Choose a reason for hiding this comment

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

@sliverc my point of tox -e devenv is you can turn these several steps into one.

Copy link
Contributor

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

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

The tox -e devenv stuff can wait for another PR if you see the value of it.

@n2ygk n2ygk merged commit 0501d70 into django-json-api:master Dec 5, 2020
@sliverc sliverc deleted the pre_commit branch December 28, 2021 18:52
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.

improve CONTRIBUTING
2 participants