Open
Bug 1199939
Opened 10 years ago
Updated 3 years ago
Automatically check for PEP 8 errors in Python code
Categories
(Firefox Build System :: Mach Core, enhancement)
Firefox Build System
Mach Core
Tracking
(Not tracked)
NEW
People
(Reporter: samy, Unassigned, Mentored)
Details
Attachments
(1 file, 2 obsolete files)
3.43 KB,
patch
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36
Reporter | ||
Comment 1•10 years ago
|
||
Hi.
I've had #1142609 as my first bug, where I manually fixed some PEP 8 errors.
Now I think it would be a good idea to have them run automatically, by users as well as the try server, in order to improve the readability of the code and make it consistent across the wide spectrum of the project [1].
I started by writing a mach command (flake8) that runs the tests on a specific directory or file, and wanted to get your opinion and advice about this potential feature.
Thank you.
[1]: https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
Reporter | ||
Comment 2•10 years ago
|
||
Reporter | ||
Updated•10 years ago
|
Mentor: sledru
Component: Untriaged → mach
Product: Firefox → Core
Version: unspecified → Trunk
Comment 3•10 years ago
|
||
Comment on attachment 8654527 [details] [diff] [review]
mach_flake8.patch
> 'jetpack': {
>- 'aliases': ('J',),
>+ 'aliases': ('f',),
> 'mach_command': 'jetpack-test',
> 'kwargs': {},
I don't think you want to do this.
me + '.exe' if sys.platform.startswith('win') else name
>
>+
>+@CommandProvider
>+class Flake8Command(MachCommandBase):
>+ @Command('flake8', category='testing', description='Run flake8 in order to find PEP 8 errors in Python code.')
-in order
>+ command = "flake8 --max-line-length=220 --select=%s $(find %s -iname '*.py'|grep -v tests)" % (filters, target)
Several things here:
* Why 220?
* What if I want to give different options?
* What is the file I want to check is called run_tests.py?
* What if I want to run on it on a test files/directory?
Reporter | ||
Comment 4•10 years ago
|
||
> * Why 220?
I'm gonna remove that line if that's okay with you.
> * What if I want to give different options?
How should it look like in your opinion?
What about `./mach flake8 testing/mach_commands.py e501 --args="--max-line-length=220"`?
Ok for the rest.
Reporter | ||
Comment 5•10 years ago
|
||
Comment 6•9 years ago
|
||
Sorry Samy, I didn't see your activity on this bug. Next time, please needinfo-me :)
* I do think that we should have max-line-length by default. I just meant that we should disable this check. Not 220.
* find %s -iname '*.py => I don't think we should do that. Will it work on Windows?
I think we should instead do that using Python code.
Hope this helps.
Updated•9 years ago
|
Assignee: nobody → samy
Reporter | ||
Comment 7•9 years ago
|
||
Added a search_files() function for multi-platform search.
Attachment #8654527 -
Attachment is obsolete: true
Attachment #8679194 -
Attachment is obsolete: true
Flags: needinfo?(sledru)
Reporter | ||
Comment 8•9 years ago
|
||
Hi Sylvestre,
> I do think that we should have max-line-length by default
Ok. What value do you suggest?
> I just meant that we should disable this check. Not 220.
I don't understand. What check exactly?
Thanks!
Comment 9•9 years ago
|
||
(In reply to Samy Dindane from comment #8)
> Hi Sylvestre,
>
> > I do think that we should have max-line-length by default
>
> Ok. What value do you suggest?
If it was possible, we could disable the check but I don't know if it is possible.
Otherwise, just a big number like 300 (random number)
Besides that, I missed the info but instead of using subprocess.call
we should use the api
http://flake8.readthedocs.org/en/latest/api.html
Flags: needinfo?(sledru)
Updated•7 years ago
|
Product: Core → Firefox Build System
Updated•7 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Comment 10•3 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.
Assignee: samy → nobody
Status: ASSIGNED → NEW
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•