Pythoscope should follow PEP8 layout guidelines for generated files

Bug #1247664 reported by brianclements on 2013-11-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pythoscope
Medium
Unassigned

Bug Description

For those of us with automatic file checkers and the like, having to clean up and reformat many many functions in the automatically generated test files that fail to meet the PEP8 guidelines seems unnecessary. I'm specifically referring to:

1) 2 blank lines in before top level functions and classes, and imports and the rest of the file
2) 2 blank spaces before in-line comments

There might be others but so far this is all I've found.

Michal Kwiatkowski (ruby) wrote :

Can you give more details, what code are you running pythoscope on?

If you run the example from the main page (http://pythoscope.org/) you won't get any of those you mentioned.

Changed in pythoscope:
status: New → Incomplete

Actually, you can even see both examples from that sample code on the front
page there. PEP8 (http://www.python.org/dev/peps/pep-0008/#blank-lines)
states for top level functions and classes, there should be 2 blank lines
in between them. In your sample code on the page there, you only have 1.

Likewise, regarding in-line comments, PEP8 (
http://www.python.org/dev/peps/pep-0008/#inline-comments) states there
should be at least 2 spaces separating the code and the comment, here you
only have one.

So modifying your example code, showing the differences in brackets, here
is the corrections:

import unittest
[2nd newline]class TestOldPython(unittest.TestCase):
    def test___init__(self):
        # old_python = OldPython(age)
        assert False []# TODO: implement your test here

    def test_hiss(self):
        # old_python = OldPython(age)
        # self.assertEqual(expected, old_python.hiss())
        assert False []# TODO: implement your test here
 if __name__ == '__main__':
    unittest.main()

I'll admit this is very nit-picky, but if it's being auto-generated, might
as well do it right. Besides, my VIM yells at me if there are any syntax
issues, so that gets old when I have dozens of functions/classes.

Brian Clements
<email address hidden>
http://brianclements.net <http://www.brianclements.net>

On Fri, Nov 8, 2013 at 2:29 AM, Michal Kwiatkowski <email address hidden> wrote:

> Can you give more details, what code are you running pythoscope on?
>
> If you run the example from the main page (http://pythoscope.org/) you
> won't get any of those you mentioned.
>
> ** Changed in: pythoscope
> Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1247664
>
> Title:
> Pythoscope should follow PEP8 layout guidelines for generated files
>
> Status in Pythoscope, the unit test generator:
> Incomplete
>
> Bug description:
> For those of us with automatic file checkers and the like, having to
> clean up and reformat many many functions in the automatically
> generated test files that fail to meet the PEP8 guidelines seems
> unnecessary. I'm specifically referring to:
>
> 1) 2 blank lines in before top level functions and classes, and imports
> and the rest of the file
> 2) 2 blank spaces before in-line comments
>
> There might be others but so far this is all I've found.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/pythoscope/+bug/1247664/+subscriptions
>

Michal Kwiatkowski (ruby) wrote :

Wow, for some reason I thought it should be the other way around. But you can't argue with pep8. ;)

I don't have time at the moment to fix this, but would gladly accept a pull request.

Two lines separating imports from the rest of the code can be fixed here: https://github.com/mkwiatkowski/pythoscope/blob/master/pythoscope/generator/adder.py#L105

while inline comments can be fixed here: https://github.com/mkwiatkowski/pythoscope/blob/d0f57da53f01004dc82efbd0bf9e0d3f04e63cb1/pythoscope/generator/builder.py#L33

Tests and docs should be updated as well.

Changed in pythoscope:
status: Incomplete → Confirmed
brianclements (brianclements) wrote :

Finally got around to it!
https://github.com/mkwiatkowski/pythoscope/pull/2

Let me know if I broke anything there, I'm still pretty new to this :D

Brian Clements
<email address hidden>
http://brianclements.net <http://www.brianclements.net>

On Fri, Nov 8, 2013 at 3:13 AM, Michal Kwiatkowski <email address hidden> wrote:

> Wow, for some reason I thought it should be the other way around. But
> you can't argue with pep8. ;)
>
> I don't have time at the moment to fix this, but would gladly accept a
> pull request.
>
> Two lines separating imports from the rest of the code can be fixed
> here:
>
> https://github.com/mkwiatkowski/pythoscope/blob/master/pythoscope/generator/adder.py#L105
>
> while inline comments can be fixed here:
>
> https://github.com/mkwiatkowski/pythoscope/blob/d0f57da53f01004dc82efbd0bf9e0d3f04e63cb1/pythoscope/generator/builder.py#L33
>
> Tests and docs should be updated as well.
>
> ** Changed in: pythoscope
> Status: Incomplete => Confirmed
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1247664
>
> Title:
> Pythoscope should follow PEP8 layout guidelines for generated files
>
> Status in Pythoscope, the unit test generator:
> Confirmed
>
> Bug description:
> For those of us with automatic file checkers and the like, having to
> clean up and reformat many many functions in the automatically
> generated test files that fail to meet the PEP8 guidelines seems
> unnecessary. I'm specifically referring to:
>
> 1) 2 blank lines in before top level functions and classes, and imports
> and the rest of the file
> 2) 2 blank spaces before in-line comments
>
> There might be others but so far this is all I've found.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/pythoscope/+bug/1247664/+subscriptions
>

Michal Kwiatkowski (ruby) wrote :

Great work, merged, thank you!

Changed in pythoscope:
status: Confirmed → Fix Committed
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers