Use pylint to look for issues on every pull request#147
Conversation
|
@diego-plan9 Not sure if we are expected to take any action but the flake8 output: ./qiskit/tools/qcvv/tomography.py:805:17: E999 IndentationError: expected an indented block is in the same place as the indentation error that happened last time - could it be being introduced by this process? |
|
Thanks @cclauss - we fully agree that we should try to minimize the amount of runtime problems and make use of automated aids to catch those as soon as possible, and it seems indeed that a couple of those errors crept into the codebase! However, as mentioned in the documentation and in #80, we are aiming to use With that in mind, could you:
|
No need to take action on this PR, @markjeveritt, as those errors should be fixed by your #146 PR! |
This would be the case if and only if pylint could catch these errors. Flake8 is a wrapper around PyFlakes, pep8, and McCabe complexity analysis so it often catches issues that are not seen by a single tool.
If pylint is unable to find such issues, then adding a tool that can in a targeted way seems useful. |
|
I put flake8 into --exit-zero mode so we can see both flake8 output and pylint output side-by-side. The good news that that pylint also catches the F821 error. The bad news is that I now understand what you mean by false positives. Pylint seems to be baffled about important methods like numpy.tan() and numpy.random.choice(). |
|
Hi @cclauss, I didn't know about flake8 and seems like it could be a good alternative to pylint in fact. Having said that, I do agree with @diego-plan9 on having just one tool for lintering, the one we choose is pretty "standard" I'd say, but we would love to hear from other options that could fit better. Therefore I was going to suggest opening a new issue and move the discussion there. |
Thanks for the confirmation! Can you try using: for working around the It seems to produce 3 errors on my setup (one of them related to Also, agreeing with @atilag , could you please remove the |
flake8 testing of https://github.com/QISKit/qiskit-sdk-py on Python 3.6.3 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./qiskit/dagcircuit/_dagcircuit.py:570:49: F821 undefined name 'n' nd = input_circuit.multi_graph.node[n] ^ ./qiskit/tools/visualization.py:463:70: E999 SyntaxError: EOL while scanning string literal """Plot the equal angle slice spin Wigner function of an arbitrary ^ ./qiskit/tools/qcvv/tomography.py:805:17: E999 IndentationError: expected an indented block W[wpt] = W[wpt]+(x[i]/shots)*parity[i] ^ 2 E999 IndentationError: expected an indented block 1 F821 undefined name 'n' 3 ```
Pylint now finds three issues. I am unable to suggest fixes for the first two. I have suggested a fix for the last issue at Qiskit@f49975e#commitcomment-25627794
|
Pylint now finds three issues. On the other two issues:
I think the n is supposed to be node but that is just a hunch. It would be best if someone more knowledgeable of this code found the correct solution.
I believe that this should be scipy.linalg.expm instead of numpy.linalg.expm. This is because numpy.linalg does not have an expm() routine and because scipy.linalg is a superset of numpy.linalg. |
|
Thanks for looking into the errors, @cclauss! Specially for taking the time for digging into the |
Fix issues raised by pylint on "--errors-only" mode, thanks to cclaus.
* QI Provider * Update community.rst JKU organization rather than authos * need double underscores at the end of ReST links in this case b/c we're using the same text in each link. * Update community.rst Doing alphabetical by organization
* Use flake8 to find syntax errors & undefined names flake8 testing of https://github.com/QISKit/qiskit-sdk-py on Python 3.6.3 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./qiskit/dagcircuit/_dagcircuit.py:570:49: F821 undefined name 'n' nd = input_circuit.multi_graph.node[n] ^ ./qiskit/tools/visualization.py:463:70: E999 SyntaxError: EOL while scanning string literal """Plot the equal angle slice spin Wigner function of an arbitrary ^ ./qiskit/tools/qcvv/tomography.py:805:17: E999 IndentationError: expected an indented block W[wpt] = W[wpt]+(x[i]/shots)*parity[i] ^ 2 E999 IndentationError: expected an indented block 1 F821 undefined name 'n' 3 ``` * pylint qiskit test --errors-only * flake8 --exit-zero to treat all issues as warnings * pylint --extension-pkg-whitelist=numpy, flake8 E999 * Remove flake8 and focus on pylint Pylint now finds three issues. I am unable to suggest fixes for the first two. I have suggested a fix for the last issue at Qiskit@f49975e#commitcomment-25627794 * Fix F821, no-member and logging-too-few-args Fix issues raised by pylint on "--errors-only" mode, thanks to cclaus. * Add numpy to the general pylint configuration
Confirms the need for #146
flake8 testing of https://github.com/QISKit/qiskit-sdk-py on Python 3.6.3
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
Description
Add flake8 to the testing to find syntax errors and undefined names. Revisits #8
Motivation and Context
We want highly reliable software that avoids runtime issues. E901,E999,F821,F822,F823 are flake8 issues than can negatively impact runtime.
How Has This Been Tested?
By running Travis CI on this and all future PRs
Screenshots (if appropriate):
Types of changes
Checklist: