From ea06980ed430d66e1a120b0e899bcbcfdaf8b49f Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Tue, 11 Feb 2020 00:08:09 +0800 Subject: [PATCH 01/16] Add tox.ini --- .gitignore | 3 ++- .travis.yml | 20 ++++++++++++-------- tox.ini | 7 +++++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index e8b7666915..e61dcb5006 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ /gh-pages/ /doc/doctrees/ .vscode* -.venv \ No newline at end of file +.venv +.tox/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index fcea1c2745..322f721853 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,18 @@ 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.6 + env: TOXENV=py37 + - python: 3.8 + env: TOXENV=py38 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/tox.ini b/tox.ini new file mode 100644 index 0000000000..8d245e1887 --- /dev/null +++ b/tox.ini @@ -0,0 +1,7 @@ +[tox] +envlist = py{36,37,38} + +[testenv] +deps = -rtest-requirements.txt +commands = + python setup.py test From 98d66fff25d8b77ab0017fe7669bf7475e49b810 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Tue, 11 Feb 2020 00:11:03 +0800 Subject: [PATCH 02/16] Fix typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 322f721853..b6f1d3a5e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ matrix: env: TOXENV=py35 - python: 3.6 env: TOXENV=py36 - - python: 3.6 + - python: 3.7 env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 From 8af8e0e630a07518a3d4fa6488c608626fb3fdd0 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Tue, 11 Feb 2020 00:13:50 +0800 Subject: [PATCH 03/16] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e61dcb5006..35d936cc9c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,4 @@ /doc/doctrees/ .vscode* .venv -.tox/ \ No newline at end of file +.tox/ From 19e143c7367d1e3e944d4852a6f882b53ece6edc Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Tue, 11 Feb 2020 00:29:36 +0800 Subject: [PATCH 04/16] Move flake8 to tox --- .flake8 | 4 ---- .travis.yml | 1 + tox.ini | 12 +++++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 .flake8 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/.travis.yml b/.travis.yml index b6f1d3a5e2..2f6b3ce7ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 + - env: TOXENV=flake8 install: - pip install tox script: diff --git a/tox.ini b/tox.ini index 8d245e1887..af266d6ed0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,17 @@ [tox] -envlist = py{36,37,38} +envlist = py{36,37,38},flake8 [testenv] deps = -rtest-requirements.txt commands = python setup.py test + +[testenv:flake8] +basepython = python3.6 +commands = flake8 {posargs} github/ +deps = flake8 + +[flake8] +max-line-length = 88 +select = C,E,F,W +ignore = E203, E266, E501, W503 From b5fc52d9ca407024a1284bc0d985e700dd0e8732 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:15:50 +0800 Subject: [PATCH 05/16] Add py35 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index af266d6ed0..b3c943f1fb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{36,37,38},flake8 +envlist = py{35,36,37,38},flake8 [testenv] deps = -rtest-requirements.txt From 64e9302f362b6cb6bb9feb28750fe8f4fe481845 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:26:07 +0800 Subject: [PATCH 06/16] Add Coverage --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b3c943f1fb..df102f3f79 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py{35,36,37,38},flake8 [testenv] deps = -rtest-requirements.txt commands = - python setup.py test + coverage run setup.py test [testenv:flake8] basepython = python3.6 From 51fbf3cf5b8383093d444526c6fd81754f2b3512 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:29:55 +0800 Subject: [PATCH 07/16] Add Coverage --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9d720e47d6..0547b78baa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: env: TOXENV=py38 - env: TOXENV=flake8 install: - - pip install tox + - pip install tox codecov script: - tox after_success: From 9d36bfae116206df804f6b78ee2f9fa289df1b17 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:37:35 +0800 Subject: [PATCH 08/16] Add Coverage --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index df102f3f79..1d72715567 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py{35,36,37,38},flake8 [testenv] deps = -rtest-requirements.txt commands = - coverage run setup.py test + coverage run --source github,tests setup.py test [testenv:flake8] basepython = python3.6 From 9d25a1a9fb3adf00729e052a093604bbd42e28cb Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:39:17 +0800 Subject: [PATCH 09/16] Add Coverage --- .travis.yml | 2 +- test-requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0547b78baa..9d720e47d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: env: TOXENV=py38 - env: TOXENV=flake8 install: - - pip install tox codecov + - pip install tox script: - tox after_success: diff --git a/test-requirements.txt b/test-requirements.txt index 48a0d018c7..86ecc2b97b 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 \ No newline at end of file From 393e93b51360d776a42e239412e0b567f8bb29d8 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:50:39 +0800 Subject: [PATCH 10/16] Add black --- tox.ini | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 1d72715567..bdafc76f66 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,22 @@ [tox] -envlist = py{35,36,37,38},flake8 +envlist = + lint, + py{35,36,37,38} [testenv] deps = -rtest-requirements.txt commands = coverage run --source github,tests setup.py test -[testenv:flake8] +[testenv:lint] basepython = python3.6 -commands = flake8 {posargs} github/ -deps = flake8 +skip_install = true +deps = + flake8 + black +commands = + flake8 github tests scripts setup.py + black --check --diff github tests scripts setup.py [flake8] max-line-length = 88 From b97704f0c326b39374c4a0ac810897d8b10f6b0f Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:53:59 +0800 Subject: [PATCH 11/16] Add black --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9d720e47d6..9a9bccd961 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 - - env: TOXENV=flake8 + - env: TOXENV=lint install: - pip install tox script: From 22b5b82baf4091abf61db5e9c884dabe2020ea53 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 01:58:28 +0800 Subject: [PATCH 12/16] Add black --- test-requirements.txt | 4 +++- tox.ini | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 86ecc2b97b..88a3fd4b0d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,6 @@ cryptography httpretty>=0.9.6 parameterized>=0.7.0 -coverage==5.0.3 \ No newline at end of file +coverage==5.0.3 +black==19.10b0 +flake8==3.7.9 \ No newline at end of file diff --git a/tox.ini b/tox.ini index bdafc76f66..5dd6f863d4 100644 --- a/tox.ini +++ b/tox.ini @@ -10,10 +10,7 @@ commands = [testenv:lint] basepython = python3.6 -skip_install = true -deps = - flake8 - black +deps = -rtest-requirements.txt commands = flake8 github tests scripts setup.py black --check --diff github tests scripts setup.py From c0b6791041df1dbe64ad4994627784a498fb0334 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 02:05:11 +0800 Subject: [PATCH 13/16] Skip black for py35 --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 88a3fd4b0d..e7b840b4ca 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,5 +2,5 @@ cryptography httpretty>=0.9.6 parameterized>=0.7.0 coverage==5.0.3 -black==19.10b0 +black==19.10b0; python_version > '3.5' flake8==3.7.9 \ No newline at end of file From a9bda1c5a723f1fb813e53d1a1ecc83354181338 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Wed, 12 Feb 2020 02:09:14 +0800 Subject: [PATCH 14/16] Add isort --- test-requirements.txt | 3 ++- tox.ini | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index e7b840b4ca..98c72a63cb 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,4 +3,5 @@ httpretty>=0.9.6 parameterized>=0.7.0 coverage==5.0.3 black==19.10b0; python_version > '3.5' -flake8==3.7.9 \ No newline at end of file +flake8==3.7.9 +isort==4.3.21 \ No newline at end of file diff --git a/tox.ini b/tox.ini index 5dd6f863d4..4a257de472 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ basepython = python3.6 deps = -rtest-requirements.txt commands = flake8 github tests scripts setup.py + isort --check -rc github tests scripts setup.py black --check --diff github tests scripts setup.py [flake8] From 6497265cb5a7d16fcec2cbc88bbddd793856dc27 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Thu, 13 Feb 2020 17:44:46 +0800 Subject: [PATCH 15/16] Update contributing docs --- .travis.yml | 4 +++- CONTRIBUTING.md | 14 +++++++++----- test-requirements.txt | 3 --- tox.ini | 40 +++++++++++++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a9bccd961..9b9c91bfbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,9 @@ matrix: env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 - - env: TOXENV=lint + - env: TOXENV=flake8 + - env: TOXENV=isort + - env: TOXENV=black install: - pip install tox script: 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 98c72a63cb..db8faa7573 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,6 +2,3 @@ cryptography httpretty>=0.9.6 parameterized>=0.7.0 coverage==5.0.3 -black==19.10b0; python_version > '3.5' -flake8==3.7.9 -isort==4.3.21 \ No newline at end of file diff --git a/tox.ini b/tox.ini index 4a257de472..56e5819ac0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,42 @@ [tox] envlist = - lint, - py{35,36,37,38} + py{35,36,37,38}, + flake8, + isort, + black [testenv] deps = -rtest-requirements.txt -commands = - coverage run --source github,tests setup.py test +commands = coverage run --source github,tests setup.py test -[testenv:lint] +[testenv:flake8] basepython = python3.6 -deps = -rtest-requirements.txt +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 = - flake8 github tests scripts setup.py - isort --check -rc github tests scripts setup.py - black --check --diff github tests scripts setup.py + isort -rc github tests scripts setup.py + black github tests scripts setup.py + [flake8] max-line-length = 88 From 847ac915a0bdc9d147fe89380ccf4367b49299a6 Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Thu, 13 Feb 2020 17:46:52 +0800 Subject: [PATCH 16/16] Remove empty line --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 56e5819ac0..1f0178809f 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,6 @@ commands = isort -rc github tests scripts setup.py black github tests scripts setup.py - [flake8] max-line-length = 88 select = C,E,F,W