After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 725621 - [patch attached] Check for PEP8 coding-style errors in Python files
[patch attached] Check for PEP8 coding-style errors in Python files
Status: RESOLVED FIXED
Product: gnome-code-assistance
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Code Assistance maintainers
GNOME Code Assistance maintainers
Depends on:
Blocks:
 
 
Reported: 2014-03-03 21:59 UTC by Elad Alfassa
Modified: 2014-03-04 19:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[backends/python] Check for PEP8 coding-style errors (2.02 KB, patch)
2014-03-03 21:59 UTC, Elad Alfassa
none Details | Review
[backends/python] Check for PEP8 coding-style errors (2.18 KB, patch)
2014-03-03 22:04 UTC, Elad Alfassa
committed Details | Review

Description Elad Alfassa 2014-03-03 21:59:08 UTC
Created attachment 270848 [details] [review]
[backends/python] Check for PEP8 coding-style errors

Patch attached :)
Comment 1 Elad Alfassa 2014-03-03 22:04:28 UTC
Created attachment 270849 [details] [review]
[backends/python] Check for PEP8 coding-style errors

Minor improvement over the previous version: don't die if PEP8 is not installed.
Comment 2 jessevdk@gmail.com 2014-03-04 07:11:36 UTC
This is nice! Two comments though:

1. PEP8 is not an actual requirement for a correct program. I wonder if we should have a way to disable certain parts of the diagnostics (i.e. like -Wno-pep8, but nicer of course). This doesn't really concern this patch specifically, but we should maybe think about implementing this in general.

2. It would be nice not to shell out if possible. I had a quick look at the pep8 module on pypi and it looks like it should be relatively easy to import it and use it directly instead of using Popen. You would also not need to parse the output afterwards but can just use its API.
Comment 3 Elad Alfassa 2014-03-04 07:39:43 UTC
I agree about #1

Regarding #2: it's not a proper API. It outputs to stdout, and if you wrap that with StringIO it blocks forever. I spent an hour and a half last night trying to make that work, and couldn't. Someone said I could change the Reporter class to make it not use print() but it's not documented well enough, the Reporter class structure is unclear and there are calls to print() everywhere even outside the Reporter class 

Using Popen is easier and also means much less lines of code. It's ugly, but it works.
Comment 4 jessevdk@gmail.com 2014-03-04 08:28:06 UTC
Ok, lets file #1 under another bug. Please go ahead and push your patch, nice work!
Comment 5 Elad Alfassa 2014-03-04 19:02:51 UTC
Review of attachment 270849 [details] [review]:

Pushed