Skip to content

tools/backport_pr: fix checks run by tox #14438

Merged
miri64 merged 3 commits intoRIOT-OS:masterfrom
aabadie:pr/tools/backport_pr_fix_tox
Jul 4, 2020
Merged

tools/backport_pr: fix checks run by tox #14438
miri64 merged 3 commits intoRIOT-OS:masterfrom
aabadie:pr/tools/backport_pr_fix_tox

Conversation

@aabadie
Copy link
Copy Markdown
Contributor

@aabadie aabadie commented Jul 4, 2020

Contribution description

This PR fixes the checks performed by tox on the backport_pr script. The changes applied here are minimal (rename variables, add missing docstrings, use sys.exit instead of exit.
Since most of the complexity of the script is in the main, I chose to silent the complexity related errors when invoking flake8 and pylint. We could keep the previous parameters but that would mean a complete rewrite of the script.

This PR also adds a docstring test to the _get_latest_release function.

Testing procedure

Run tox from the dist/tools/backport_pr directory:

this PR:
$ cd dist/tools/backport_pr
$ tox --recreate
test recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/test
test installdeps: pytest, -r/work/riot/RIOT/dist/tools/backport_pr/requirements.txt
test installed: agithub==2.1,attrs==19.3.0,gitdb2==2.0.3,GitPython==2.1.9,more-itertools==8.4.0,packaging==20.4,pluggy==0.13.1,py==1.9.0,pyparsing==2.4.7,pytest==5.4.3,six==1.15.0,smmap2==2.0.3,wcwidth==0.2.5
test run-test-pre: PYTHONHASHSEED='167647392'
test run-test: commands[0] | pytest -v --doctest-modules backport_pr.py
============================================================ test session starts ============================================================
platform linux -- Python 3.8.2, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /work/riot/RIOT/dist/tools/backport_pr/.tox/test/bin/python
cachedir: .tox/test/.pytest_cache
rootdir: /work/riot/RIOT/dist/tools/backport_pr
collected 3 items                                                                                                                           

backport_pr.py::backport_pr._branch_name_strip PASSED                                                                                 [ 33%]
backport_pr.py::backport_pr._get_labels PASSED                                                                                        [ 66%]
backport_pr.py::backport_pr._get_latest_release PASSED                                                                                [100%]

============================================================= 3 passed in 0.06s =============================================================
lint recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/lint
lint installdeps: pylint, -r/work/riot/RIOT/dist/tools/backport_pr/requirements.txt
lint installed: agithub==2.1,astroid==2.4.2,gitdb2==2.0.3,GitPython==2.1.9,isort==4.3.21,lazy-object-proxy==1.4.3,mccabe==0.6.1,pylint==2.5.3,six==1.15.0,smmap2==2.0.3,toml==0.10.1,wrapt==1.12.1
lint run-test-pre: PYTHONHASHSEED='167647392'
lint run-test: commands[0] | pylint --disable=fixme backport_pr.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

flake8 recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/flake8
flake8 installdeps: flake8
flake8 installed: flake8==3.8.3,mccabe==0.6.1,pycodestyle==2.6.0,pyflakes==2.2.0
flake8 run-test-pre: PYTHONHASHSEED='167647392'
flake8 run-test: commands[0] | flake8 --max-complexity=25 backport_pr.py
__________________________________________________________________ summary __________________________________________________________________
  test: commands succeeded
  lint: commands succeeded
  flake8: commands succeeded
  congratulations :)
master:
$ cd dist/tools/backport_pr
$ tox --recreate
test recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/test
test installdeps: pytest, -r/work/riot/RIOT/dist/tools/backport_pr/requirements.txt
test installed: agithub==2.1,attrs==19.3.0,gitdb2==2.0.3,GitPython==2.1.9,more-itertools==8.4.0,packaging==20.4,pluggy==0.13.1,py==1.9.0,pyparsing==2.4.7,pytest==5.4.3,six==1.15.0,smmap2==2.0.3,wcwidth==0.2.5
test run-test-pre: PYTHONHASHSEED='1175415831'
test run-test: commands[0] | pytest -v --doctest-modules backport_pr.py
============================================================ test session starts ============================================================
platform linux -- Python 3.8.2, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /work/riot/RIOT/dist/tools/backport_pr/.tox/test/bin/python
cachedir: .tox/test/.pytest_cache
rootdir: /work/riot/RIOT/dist/tools/backport_pr
collected 2 items                                                                                                                           

backport_pr.py::backport_pr._branch_name_strip PASSED                                                                                 [ 50%]
backport_pr.py::backport_pr._get_labels PASSED                                                                                        [100%]

============================================================= 2 passed in 0.06s =============================================================
lint recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/lint
lint installdeps: pylint, -r/work/riot/RIOT/dist/tools/backport_pr/requirements.txt
lint installed: agithub==2.1,astroid==2.4.2,gitdb2==2.0.3,GitPython==2.1.9,isort==4.3.21,lazy-object-proxy==1.4.3,mccabe==0.6.1,pylint==2.5.3,six==1.15.0,smmap2==2.0.3,toml==0.10.1,wrapt==1.12.1
lint run-test-pre: PYTHONHASHSEED='1175415831'
lint run-test: commands[0] | pylint backport_pr.py
************* Module backport_pr
backport_pr.py:133:2: W0511: TODO: exception handling (fixme)
backport_pr.py:1:0: C0114: Missing module docstring (missing-module-docstring)
backport_pr.py:35:0: C0103: Argument name "pr" doesn't conform to snake_case naming style (invalid-name)
backport_pr.py:105:0: C0116: Missing function or method docstring (missing-function-docstring)
backport_pr.py:105:0: R0914: Too many local variables (34/15) (too-many-locals)
backport_pr.py:132:4: C0103: Variable name "g" doesn't conform to snake_case naming style (invalid-name)
backport_pr.py:137:8: R1722: Consider using sys.exit() (consider-using-sys-exit)
backport_pr.py:151:8: R1722: Consider using sys.exit() (consider-using-sys-exit)
backport_pr.py:159:8: R1722: Consider using sys.exit() (consider-using-sys-exit)
backport_pr.py:194:8: R1722: Consider using sys.exit() (consider-using-sys-exit)
backport_pr.py:239:8: C0103: Variable name "pr" doesn't conform to snake_case naming style (invalid-name)
backport_pr.py:105:0: R0912: Too many branches (22/12) (too-many-branches)
backport_pr.py:105:0: R0915: Too many statements (102/50) (too-many-statements)

-------------------------------------------------------------------
Your code has been rated at 9.17/10 (previous run: 10.00/10, -0.83)

ERROR: InvocationError for command /work/riot/RIOT/dist/tools/backport_pr/.tox/lint/bin/pylint backport_pr.py (exited with code 28)
flake8 recreate: /work/riot/RIOT/dist/tools/backport_pr/.tox/flake8
flake8 installdeps: flake8
flake8 installed: flake8==3.8.3,mccabe==0.6.1,pycodestyle==2.6.0,pyflakes==2.2.0
flake8 run-test-pre: PYTHONHASHSEED='1175415831'
flake8 run-test: commands[0] | flake8 --max-complexity=10 backport_pr.py
backport_pr.py:39:80: E501 line too long (94 > 79 characters)
backport_pr.py:105:1: C901 'main' is too complex (21)
ERROR: InvocationError for command /work/riot/RIOT/dist/tools/backport_pr/.tox/flake8/bin/flake8 --max-complexity=10 backport_pr.py (exited with code 1)
__________________________________________________________________ summary __________________________________________________________________
  test: commands succeeded
ERROR:   lint: commands failed
ERROR:   flake8: commands failed

Issues/PRs references

None

@aabadie aabadie added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: tools Area: Supplementary tools CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs labels Jul 4, 2020
@aabadie aabadie requested a review from miri64 July 4, 2020 14:15
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

LGTM but could use some documentation for posterity.

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

ACK. tox passes on my machine

Details
test installed: agithub==2.1,attrs==19.3.0,gitdb2==2.0.3,GitPython==2.1.9,more-itertools==8.4.0,packaging==20.4,pluggy==0.13.1,py==1.9.0,pyparsing==2.4.7,pytest==5.4.3,six==1.15.0,smmap2==2.0.3,wcwidth==0.2.5
test run-test-pre: PYTHONHASHSEED='1405377039'
test run-test: commands[0] | pytest -v --doctest-modules backport_pr.py
===================================================================== test session starts ======================================================================
platform linux -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /home/mlenders/Repositories/RIOT-OS/RIOT/dist/tools/backport_pr/.tox/test/bin/python
cachedir: .tox/test/.pytest_cache
rootdir: /home/mlenders/Repositories/RIOT-OS/RIOT/dist/tools/backport_pr
collected 3 items                                                                                                                                              

backport_pr.py::backport_pr._branch_name_strip PASSED                                                                                                    [ 33%]
backport_pr.py::backport_pr._get_labels PASSED                                                                                                           [ 66%]
backport_pr.py::backport_pr._get_latest_release PASSED                                                                                                   [100%]

====================================================================== 3 passed in 0.11s =======================================================================
lint installed: agithub==2.1,astroid==2.4.2,gitdb2==2.0.3,GitPython==2.1.9,isort==4.3.21,lazy-object-proxy==1.4.3,mccabe==0.6.1,pylint==2.5.3,six==1.15.0,smmap2==2.0.3,toml==0.10.1,wrapt==1.12.1
lint run-test-pre: PYTHONHASHSEED='1405377039'
lint run-test: commands[0] | pylint --disable=fixme backport_pr.py

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.17/10, +0.83)

flake8 installed: flake8==3.8.3,mccabe==0.6.1,pycodestyle==2.6.0,pyflakes==2.2.0
flake8 run-test-pre: PYTHONHASHSEED='1405377039'
flake8 run-test: commands[0] | flake8 --max-complexity=25 backport_pr.py
___________________________________________________________________________ summary ____________________________________________________________________________
  test: commands succeeded
  lint: commands succeeded
  flake8: commands succeeded
  congratulations :)

@aabadie aabadie force-pushed the pr/tools/backport_pr_fix_tox branch from 24550a9 to dfa9979 Compare July 4, 2020 16:25
@miri64 miri64 merged commit c56147d into RIOT-OS:master Jul 4, 2020
@miri64 miri64 added this to the Release 2020.07 milestone Jul 5, 2020
@aabadie aabadie deleted the pr/tools/backport_pr_fix_tox branch August 2, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants