Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
n2ygk merged 3 commits into django-json-api:master from sliverc:pre_commit
Dec 5, 2020

Conversation

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
Copy link

codecov bot commented Nov 22, 2020
edited
Loading

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 '\n033円[0;31m dont forget to source env/bin/activate033円[0m\n'

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
Reviewers

@n2ygk n2ygk n2ygk approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

improve CONTRIBUTING
2 participants

AltStyle によって変換されたページ (->オリジナル) /