Bug 10789

Summary: patchtest-oe: Include a test case that fails in case pylint issues are found on new patch changes
Product: [Yocto Project Subprojects] Patchwork/Patchtest Reporter: Leonardo Sandoval Gonzalez <leonardo.sandoval.gonzalez>
Component: Patchtest TestsuiteAssignee: Daniela Plascencia <daniela.plascencia>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium+ CC: bluelightning
Version: 2.3   
Target Milestone: 2.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Leonardo Sandoval Gonzalez 2016-12-12 14:50:55 UTC
Currently there is a pylint check at the repository but the output is not the desired one. Current logic may be broken. Also we need to investigate if pylint can warn just a set of checks that the project is interested.
Comment 1 Daniela Plascencia 2016-12-22 18:42:28 UTC
The check at patchtest-oe has now changed from its first version, but I'm currently facing two issues with pylint's execution within the patchtest environment:

- Pylint throwing import errors. 

If we take, for instance poky/bitbake/lib/bb/command.py, the imports are done as:

import bb.event
import bb.cooker
import bb.remotedata

In order to test it, Pylint runs 'command.py' inside 'bb/', which indeed causes a Python ImportError, and thus the check fails, meaning all patches having files importing modules in such fashion will be marked as failures. We must find a way to handle these files.

- Pylint's message template is already defined at epylint.py (/usr/lib/python2.7/site-packages/pylint/epylint.py)

The pylint check at patchtest-oe uses the py_run method from epylint.py to be ran. The content at epylint defines Pylint's message template, which is the way the results are displayed to the user and can be modified to show certain information(e.g. line number, type of error) [1], but the latter can be done only from epylint.py. We must find a way to set the msg-template from within the check at patchtest-oe.

[1] https://docs.pylint.org/en/1.6.0/output.html
Comment 2 Leonardo Sandoval Gonzalez 2016-12-23 16:06:14 UTC
(In reply to comment #1)
> The check at patchtest-oe has now changed from its first version, but I'm
> currently facing two issues with pylint's execution within the patchtest
> environment:
> 
> - Pylint throwing import errors. 
> 
> If we take, for instance poky/bitbake/lib/bb/command.py, the imports are
> done as:
> 
> import bb.event
> import bb.cooker
> import bb.remotedata
> 
> In order to test it, Pylint runs 'command.py' inside 'bb/', which indeed
> causes a Python ImportError, and thus the check fails, meaning all patches
> having files importing modules in such fashion will be marked as failures.
> We must find a way to handle these files.
> 

Let's ignore import errors. pylint is not being run from the bitbake script, so this is the reason that the PYTHONPATH is not set and some libraries cannot be found.

> - Pylint's message template is already defined at epylint.py
> (/usr/lib/python2.7/site-packages/pylint/epylint.py)
> 
> The pylint check at patchtest-oe uses the py_run method from epylint.py to
> be ran. The content at epylint defines Pylint's message template, which is
> the way the results are displayed to the user and can be modified to show
> certain information(e.g. line number, type of error) [1], but the latter can
> be done only from epylint.py. We must find a way to set the msg-template
> from within the check at patchtest-oe.

Right. we should not touch the python-pylint module. Please ask the pylint community if you need info about it.

> 
> [1] https://docs.pylint.org/en/1.6.0/output.html
Comment 3 Daniela Plascencia 2017-01-05 21:17:50 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > The check at patchtest-oe has now changed from its first version, but I'm
> > currently facing two issues with pylint's execution within the patchtest
> > environment:
> > 
> > - Pylint throwing import errors. 
> > 
> > If we take, for instance poky/bitbake/lib/bb/command.py, the imports are
> > done as:
> > 
> > import bb.event
> > import bb.cooker
> > import bb.remotedata
> > 
> > In order to test it, Pylint runs 'command.py' inside 'bb/', which indeed
> > causes a Python ImportError, and thus the check fails, meaning all patches
> > having files importing modules in such fashion will be marked as failures.
> > We must find a way to handle these files.
> > 
> 
> Let's ignore import errors. pylint is not being run from the bitbake script,
> so this is the reason that the PYTHONPATH is not set and some libraries
> cannot be found.
> 

Ok. Adding the option to ignore import errors will solve this issue.

> > - Pylint's message template is already defined at epylint.py
> > (/usr/lib/python2.7/site-packages/pylint/epylint.py)
> > 
> > The pylint check at patchtest-oe uses the py_run method from epylint.py to
> > be ran. The content at epylint defines Pylint's message template, which is
> > the way the results are displayed to the user and can be modified to show
> > certain information(e.g. line number, type of error) [1], but the latter can
> > be done only from epylint.py. We must find a way to set the msg-template
> > from within the check at patchtest-oe.
> 
> Right. we should not touch the python-pylint module. Please ask the pylint
> community if you need info about it.

The issue with the message template is now tracked at https://github.com/PyCQA/pylint/issues/1269.

> 
> > 
> > [1] https://docs.pylint.org/en/1.6.0/output.html
Comment 4 Leonardo Sandoval Gonzalez 2017-01-25 16:43:55 UTC
pylint check is not ready so moving to the M3.