diff --git a/.flake8 b/.flake8 deleted file mode 100644 index a9b6f3bbfb..0000000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 88 -select = C,E,F,W -ignore = E203, E266, E501, W503 diff --git a/.gitignore b/.gitignore index e8b7666915..35d936cc9c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ /gh-pages/ /doc/doctrees/ .vscode* -.venv \ No newline at end of file +.venv +.tox/ diff --git a/.travis.yml b/.travis.yml index 452174799c..9b9c91bfbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,21 @@ language: python -python: - - "3.5" - - "3.6" - - "3.7" - - "3.8" +matrix: + include: + - python: 3.5 + env: TOXENV=py35 + - python: 3.6 + env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 + - python: 3.8 + env: TOXENV=py38 + - env: TOXENV=flake8 + - env: TOXENV=isort + - env: TOXENV=black install: - - pip install codecov flake8 + - pip install tox script: - - flake8 - - coverage run --source github,tests setup.py test + - tox after_success: - codecov notifications: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fead8c007..5560852001 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,15 @@ Pull Requests should clearly describe two things: Ideally, changes should be made in logical commits and tests added to improve the project's coverage of the GitHub API. +## Coding conventions + +PyGithub adopts the black coding style and uses isort to sort imports. + +To manually format the code: +``` +tox -e format +``` + ## Adding missing attributes for a GithubObject ```bash @@ -84,11 +93,6 @@ To run manual tests with external scripts that use the PyGithub package, you can pip install --editable path/to/project ``` -## Coding conventions - -PyGithub follows [pep8 Style Guide for Python Code](http://www.python.org/dev/peps/pep-0008/) except for line length. -Please check your code with [pep8 Python style guide checker](http://pypi.python.org/pypi/pep8), by running `pep8 --ignore=E501 github`. - ## Build documentation locally ``` diff --git a/test-requirements.txt b/test-requirements.txt index 48a0d018c7..db8faa7573 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ cryptography httpretty>=0.9.6 parameterized>=0.7.0 +coverage==5.0.3 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..1f0178809f --- /dev/null +++ b/tox.ini @@ -0,0 +1,43 @@ +[tox] +envlist = + py{35,36,37,38}, + flake8, + isort, + black + +[testenv] +deps = -rtest-requirements.txt +commands = coverage run --source github,tests setup.py test + +[testenv:flake8] +basepython = python3.6 +skip_install = true +deps = flake8 +commands = flake8 github tests scripts setup.py + +[testenv:isort] +basepython = python3.6 +skip_install = true +deps = isort +commands = isort --check -rc github tests scripts setup.py + +[testenv:black] +basepython = python3.6 +skip_install = true +deps = black +commands = black --check --diff github tests scripts setup.py + +[testenv:format] +basepython = python3.6 +skip_install = true +deps = + black + isort +commands = + isort -rc github tests scripts setup.py + black github tests scripts setup.py + +[flake8] +max-line-length = 88 +select = C,E,F,W +ignore = E203, E266, E501, W503