diff --git a/.travis.yml b/.travis.yml index 0290eea64..143d95253 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - pip install -r requirements-dev.txt script: - nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ + - yapf -r telegram - flake8 telegram - 'if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then pylint -E telegram --disable=no-name-in-module,import-error; fi' after_success: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index c5e6cfcb3..91a64a99b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -22,6 +22,11 @@ Setting things up ``$ pip install -r requirements.txt -r requirements-dev.txt`` + +5. Install pre-commit hooks: + + ``$ pre-commit install`` + Finding something to do ----------------------- @@ -68,18 +73,20 @@ Here's how to make a one-off code change. - Add yourself to the AUTHORS.rst_ file in an alphabetical fashion. - - Before making a commit ensure that all automated tests, pep8 & lint validations still pass: + - Before making a commit ensure that all automated tests still pass: ``$ make test`` - ``$ make pep8`` + - To actually make the commit (this will trigger test for yapf, lint and pep8 automatically): - ``$ make lint`` + ``$ git add your-file-changed.py`` - - To actually make the commit and push it to your GitHub fork, run: + - yapf may change code formatting, make sure to re-add them to your commit. ``$ git commit -a -m "your-commit-message-here"`` + - Finally, push it to your GitHub fork, run: + ``$ git push origin your-branch-name`` 4. **When your feature is ready to merge, create a pull request.** diff --git a/Makefile b/Makefile index 6fdcfd183..85bc6b813 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ .DEFAULT_GOAL := help -.PHONY: clean pep8 lint test install +.PHONY: clean pep257 pep8 yapf lint test install PYLINT := pylint NOSETESTS := nosetests PEP257 := pep257 PEP8 := flake8 +YAPF := yapf PIP := pip clean: @@ -19,7 +20,10 @@ pep257: $(PEP257) telegram pep8: - $(PEP8) telegram + $(PEP8) telegram + +yapf: + $(YAPF) -r telegram lint: $(PYLINT) -E telegram --disable=no-name-in-module,import-error @@ -36,6 +40,7 @@ help: @echo "- pep257 Check docstring style with pep257" @echo "- pep8 Check style with flake8" @echo "- lint Check style with pylint" + @echo "- yapf Check style with yapf" @echo "- test Run tests" @echo @echo "Available variables:" @@ -43,4 +48,5 @@ help: @echo "- NOSETESTS default: $(NOSETESTS)" @echo "- PEP257 default: $(PEP257)" @echo "- PEP8 default: $(PEP8)" + @echo "- YAPF default: $(YAPF)" @echo "- PIP default: $(PIP)"