Menu

#214 Taurus4: all code should be PEP8 compliant

I['Jul16', '']
resolved
taurus4 (70)
bug
2016-07-15
2015-11-23
No

Pass autopep8 to all code prior to taurus4 release.

See related ticket in sardana:
https://sourceforge.net/p/sardana/tickets/81/

Discussion

  • Carlos Pascual

    Carlos Pascual - 2015-11-27

    Hi, I post here my reply to a privately sent email from srubio which I think is interesting for debating in the community:

    On Fri 27 November 2015 13:58:35 Sergi Rubio wrote:

    Regarding PEP8, me and Dani had some recent issues with highly nested
    code and/or very long device names or paths. Summarizing, applying
    autopep8 (or whatever pycharm does) converted some list comprehensions
    or string operations in unreadable mumbling.

    Can you please provide a pointer to the code that was "unreadable mumbling"?

    Note that we haven't yet applied any autopep8 (either explicitly or via an IDE) on Taurus code, but I am right now testing autopep8 on my local branch in order to close https://sourceforge.net/p/tauruslib/tickets/214/

    So I am interested in collecting the "ugly" cases from applying autopep8 in order to weight them in for the resolution of the above ticket. (one of these is already mentioned in
    https://sourceforge.net/p/sardana/tickets/81/ )

    Apart of unreadability, I feel that the auto-line breaking discourages
    to use list processing; which is more or less like castrating the
    python syntax.

    PEP8 discourages that and also many other forms of python syntax (that's what it is all about!). In this case, I agree with PEP8 in considering the long comprehensions harmful (they are difficult to read, difficult to debug and a hell for code review when you use diff to evaluate changes).

    But, I recovered some faith in mankind after I saw in your link that
    max-length of lines is something that can be negotiated (100 is used
    as example).

    I would not go as far as 180 or 200 chars, ... But could we please all
    agree on 120 line length instead of 80?

    I think 120 would be just enough to fit basic condition syntax and
    reserve line-breaking for iterables.

    More than 1 year ago we decided that all new code for taurus and sardana should adhere to the 80 chars limit (we try to enforce it during the integration process).

    At the beginning it was frustrating and we were tempted to relax this limit, because we didn't like being forced to write indirections in the code. E.g., instead of writing:

    if car_make not in ['Renault', 'Porshe', 'Mercedes',  'Citroen']
        ...
    

    we had to write:

    cars = ['Renault', 'Porshe', 'Mercedes',  'Citroen']
    if car_make not in cars:
        ...
    

    But it turned out that it is all a matter of habit, and once we got used, it feels natural and we do not feel constrained. We just switched the code style to something that among other things, is more legible and far easier to debug.

    So, if the last 8 months experience is worth something, I would prefer to stick to the standard of 80 lines because, apart of leading to more readable code, it has the following advantages:

    • It is the most common standard (it helps when transporting code to or from other projects)

    • It facilitates copying code snippets to/from email (for discussions, etc)

    • It helps when using a side-by-side diff tool (such as meld)

    • (...) see PEP8

     
  • Carlos Pascual

    Carlos Pascual - 2015-12-01

    Hi,
    Here are some results of my tests with autopep8. Basically I ran autopep8 with increasing level of aggressiveness, doing a commit and running the testsuite and a flake8 check at each step (see command history at the bottom).

    Conclussions:

    • It is important to use the latest autopep8 (1.2.1) . Debian9 provides 0.9.1 which does not behave well with the --exclude option
    • anything above the default level of agressiveness breaks some unittests, so I suggest not doing it (one of the culprits of the breaks seems to be W601: "use in instead of has_key" [1], because of taurus Enumeration defining has_key!, although E721 and E712 also break the unittests)
    • ...but it may be worth to try to selectively apply some more fixes (I'll post another comment with that)

    [1] https://pypi.python.org/pypi/autopep8#features

    Also if you are interested in seeing the effects in the actual code, you can check out the resulting branch from here
    https://sourceforge.net/u/cmft/ctgensoft-taurus/ci/taurus4-pep8/tree/

    Command history

    cpascual@pc218:~/src/taurus(taurus4-pep8)$ mkvirtualenv pep8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ pip install flake8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ pip install autopep8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ workon pep8  # in principle not needed, but I was getting system autopep8 (v 0.9.1)...
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    3       E101 indentation contains mixed spaces and tabs
    46      E111 indentation is not a multiple of four
    22      E112 expected an indented block
    36      E113 unexpected indentation
    6       E121 continuation line under-indented for hanging indent
    151     E122 continuation line missing indentation or outdented
    22      E124 closing bracket does not match visual indentation
    2       E125 continuation line with same indent as next logical line
    38      E126 continuation line over-indented for hanging indent
    178     E127 continuation line over-indented for visual indent
    331     E128 continuation line under-indented for visual indent
    4       E129 visually indented line with same indent as next logical line
    12      E131 continuation line unaligned for hanging indent
    149     E201 whitespace after '('
    144     E202 whitespace before ')'
    474     E203 whitespace before ':'
    42      E211 whitespace before '('
    59      E221 multiple spaces before operator
    42      E222 multiple spaces after operator
    809     E225 missing whitespace around operator
    46      E227 missing whitespace around bitwise or shift operator
    418     E228 missing whitespace around modulo operator
    3931    E231 missing whitespace after ':'
    724     E251 unexpected spaces around keyword / parameter equals
    599     E261 at least two spaces before inline comment
    504     E262 inline comment should start with '# '
    7703    E265 block comment should start with '# '
    25      E271 multiple spaces after keyword
    9       E272 multiple spaces before keyword
    118     E301 expected 1 blank line, found 0
    572     E302 expected 2 blank lines, found 1
    182     E303 too many blank lines (2)
    61      E304 blank lines found after function decorator
    23      E401 multiple imports on one line
    4558    E501 line too long (81 > 79 characters)
    88      E502 the backslash is redundant between brackets
    986     E701 multiple statements on one line (colon)
    1       E702 multiple statements on one line (semicolon)
    5       E703 statement ends with a semicolon
    15      E711 comparison to None should be 'if cond is not None:'
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 328
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    2       W191 indentation contains tabs
    3501    W291 trailing whitespace
    69      W292 no newline at end of file
    5755    W293 blank line contains whitespace
    93      W391 blank line at end of file
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    33140
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 469 tests in 42.956s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 --version
    autopep8 1.2.1
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    2       E127 continuation line over-indented for visual indent
    821     E265 block comment should start with '# '
    2889    E501 line too long (81 > 79 characters)
    15      E711 comparison to None should be 'if cond is not None:'
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 378
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    812     W291 trailing whitespace
    64      W293 blank line contains whitespace
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    5194
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 469 tests in 49.545s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ commit -a -m "Apply autopep8 (first time)"
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 -a -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    1       E125 continuation line with same indent as next logical line
    821     E265 block comment should start with '# '
    2711    E501 line too long (81 > 79 characters)
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    171     F401 'operator' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    8       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 385
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    3       W601 .has_key() is deprecated, use 'in'
    4075
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 449 tests in 31.097s
    
    FAILED (failures=5, errors=6, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ commit -a -m "Apply autopep8 -a"
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 -a -a -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    2       E125 continuation line with same indent as next logical line
    821     E265 block comment should start with '# '
    2182    E501 line too long (81 > 79 characters)
    2       E712 comparison to False should be 'if cond is False:' or 'if not cond:'
    10      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    171     F401 'operator' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    8       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 389
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    3       W601 .has_key() is deprecated, use 'in'
    3535
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 449 tests in 28.012s
    
    FAILED (failures=5, errors=6, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ commit -a -m "Apply autopep8 -a -a"
    
     
  • Carlos Pascual

    Carlos Pascual - 2015-12-01

    Further tests applying some fixes selectively and keeping them only if they seem inoquous (i.e., do not break the tests and a quick review seems ok).

    I also checked the results on the code and based on all this I recommend the following recipe (see the note about the last commit below):

    • apply autopep8 (with default aggressive level=0)
    • then selectively fix E711, E713, E291, E293
    • do not apply the E501 (hence reversion of last commit in [1])

    The code changes can be found here:
    https://sourceforge.net/u/cmft/ctgensoft-taurus/ci/taurus4-pep8-finetune/tree/

    Command history (starting from the "Apply autopep8 (first time)" commit):

    cpascual@pc218:~/src/taurus(taurus4-pep8)$ mkvirtualenv pep8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ pip install flake8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ pip install autopep8
    (...)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ workon pep8  # in principle not needed, but I was getting system autopep8 (v 0.9.1)...
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    3       E101 indentation contains mixed spaces and tabs
    46      E111 indentation is not a multiple of four
    22      E112 expected an indented block
    36      E113 unexpected indentation
    6       E121 continuation line under-indented for hanging indent
    151     E122 continuation line missing indentation or outdented
    22      E124 closing bracket does not match visual indentation
    2       E125 continuation line with same indent as next logical line
    38      E126 continuation line over-indented for hanging indent
    178     E127 continuation line over-indented for visual indent
    331     E128 continuation line under-indented for visual indent
    4       E129 visually indented line with same indent as next logical line
    12      E131 continuation line unaligned for hanging indent
    149     E201 whitespace after '('
    144     E202 whitespace before ')'
    474     E203 whitespace before ':'
    42      E211 whitespace before '('
    59      E221 multiple spaces before operator
    42      E222 multiple spaces after operator
    809     E225 missing whitespace around operator
    46      E227 missing whitespace around bitwise or shift operator
    418     E228 missing whitespace around modulo operator
    3931    E231 missing whitespace after ':'
    724     E251 unexpected spaces around keyword / parameter equals
    599     E261 at least two spaces before inline comment
    504     E262 inline comment should start with '# '
    7703    E265 block comment should start with '# '
    25      E271 multiple spaces after keyword
    9       E272 multiple spaces before keyword
    118     E301 expected 1 blank line, found 0
    572     E302 expected 2 blank lines, found 1
    182     E303 too many blank lines (2)
    61      E304 blank lines found after function decorator
    23      E401 multiple imports on one line
    4558    E501 line too long (81 > 79 characters)
    88      E502 the backslash is redundant between brackets
    986     E701 multiple statements on one line (colon)
    1       E702 multiple statements on one line (semicolon)
    5       E703 statement ends with a semicolon
    15      E711 comparison to None should be 'if cond is not None:'
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 328
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    2       W191 indentation contains tabs
    3501    W291 trailing whitespace
    69      W292 no newline at end of file
    5755    W293 blank line contains whitespace
    93      W391 blank line at end of file
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    33140
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 469 tests in 42.956s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 --version
    autopep8 1.2.1
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ autopep8 -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    2       E127 continuation line over-indented for visual indent
    821     E265 block comment should start with '# '
    2889    E501 line too long (81 > 79 characters)
    15      E711 comparison to None should be 'if cond is not None:'
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 378
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    812     W291 trailing whitespace
    64      W293 blank line contains whitespace
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    5194
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 469 tests in 49.545s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8)$ commit -a -m "Apply autopep8 (first time)"
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ autopep8 -a -irv --select="E711" --exclude="*/taurus/external/*" lib doc scripts setup.py
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    2       E127 continuation line over-indented for visual indent
    821     E265 block comment should start with '# '
    2889    E501 line too long (81 > 79 characters)
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    16      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 378
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    812     W291 trailing whitespace
    64      W293 blank line contains whitespace
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    5179
    
    $ devenv python lib/taurus/test/testsuite.py
    Ran 469 tests in 44.814s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ commit -a -m "Apply autopep8 for E711"
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ autopep8 -a -a -irv --select="E713" --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    2       E127 continuation line over-indented for visual indent
    821     E265 block comment should start with '# '
    2889    E501 line too long (81 > 79 characters)
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    10      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 378
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    812     W291 trailing whitespace
    64      W293 blank line contains whitespace
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    5173
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ devenv python lib/taurus/test/testsuite.py
    Ran 469 tests in 39.615s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ commit -a -m "Apply autopep8 for E713"
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ autopep8 -a -a -irv --select="W291,W293" --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E124 closing bracket does not match visual indentation
    2       E127 continuation line over-indented for visual indent
    821     E265 block comment should start with '# '
    2889    E501 line too long (81 > 79 characters)
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    10      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 378
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    4297
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ devenv python lib/taurus/test/testsuite.py
    Ran 469 tests in 50.146s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ commit -a -m "Apply autopep8 for E291,293"
    

    IMPORTANT:
    The following step (corresponding to the last commit of the taurus4-pep8-finetuning branch) fixes ~25% of the E501 errors, but IMHO it leaves pretty ugly code. I suggest not to do it and instead just fix those lines by hand when we run into them

    autopep8 -a -a -irv --select="E501" --exclude="*/taurus/external/*" lib doc scripts setup.py
    autopep8 -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    8       E111 indentation is not a multiple of four
    1       E125 continuation line with same indent as next logical line
    821     E265 block comment should start with '# '
    2194    E501 line too long (81 > 79 characters)
    7       E712 comparison to True should be 'if cond is True:' or 'if cond:'
    10      E713 test for membership should be 'not in'
    29      E714 test for object identity should be 'is not'
    5       E721 do not compare types, use 'isinstance()'
    160     F401 '__qt' imported but unused
    166     F403 'from core.taurushelper import *' used; unable to detect undefined names
    7       F811 redefinition of unused 'sys' from line 32
    4       F812 list comprehension redefines 'row' from line 395
    31      F821 undefined name 'self'
    4       F822 undefined name 'TaurusNexusBrowser' in __all__
    94      F841 local variable 'ok' is assigned to but never used
    41      W601 .has_key() is deprecated, use 'in'
    18      W602 deprecated form of raising exception
    3600
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ devenv python lib/taurus/test/testsuite.py
    Ran 469 tests in 40.480s
    
    FAILED (failures=6, errors=3, skipped=5)
    
    cpascual@pc218:~/src/taurus(taurus4-pep8-finetune)$ commit -a -m "Apply autopep8 for E501 and then all"
    
     
  • Carlos Pascual

    Carlos Pascual - 2015-12-01

    Once we agree in the recipe, I suggest to apply it right after the merge of taurus4-preview into develop (to avoid merge conflicts).

     
  • Carlos Pascual

    Carlos Pascual - 2015-12-01
    • status: waiting --> active
    • assigned_to: Carlos Pascual
     
  • Carlos Pascual

    Carlos Pascual - 2016-02-29

    Recipe from the above comment applied to taurus4-preview branch.

    Things to note:

    • All unittests successful after application
    • flake8 issues reduced from 32660 to 4193
    • Only conservative changes applied (the standard ones + E711. E713, W291, W293)
    • taurus.external modules not touched
    • The resulting taurus4-preview branch [#1bff80] can be merged without conflicts with the current develop [#5e822b]

    Below is a short log (I used 2 terminals, which appear as term1 and term2). A more detailed log is attached (and can also be seen in the commit messages)

    ###(term1)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    (...)
    32660
    
    ###(term2)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 558 tests in 51.509s
    
    OK (skipped=10)
    
    ###(term1)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ autopep8 -ir --exclude="*/taurus/external/*" lib doc scripts setup.py
    
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    (...)
    5054
    
    ###(term2)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 558 tests in 41.615s
    
    OK (skipped=10)
    
    ###(term1)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ autopep8 -a -irv --select="E711" --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    (...)
    5039
    
    ###(term2)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 558 tests in 40.189s
    
    OK (skipped=10)
    
    ###(term1)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ autopep8 -a -a -irv --select="E713" --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.py --exclude="lib/taurus/external/*"
    (...)
    5033
    
    ###(term2)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 558 tests in 41.833s
    
    OK (skipped=10)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ git commit -a # "Apply autopep8 for E713"
    
    ***************** ^^^^^^^^^^^^ COMMIT 3 ^^^^^^^^^^^^ *********
    
    ###(term1)
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ autopep8 -a -a -irv --select="W291,W293" --exclude="*/taurus/external/*" lib doc scripts setup.py
    (pep8)cpascual@pc218:~/src/taurus(taurus4-preview)$ flake8 -qq --count --statistics lib doc scripts setup.
    (...)
    4193
    
    ###(term2)
    cpascual@pc218:~/src/taurus(taurus4-preview)$ devenv python lib/taurus/test/testsuite.py
    (...)
    Ran 558 tests in 40.323s
    
    OK (skipped=10)
    
     
  • Carlos Pascual

    Carlos Pascual - 2016-02-29
    • status: active --> resolved
     
  • Carlos Pascual

    Carlos Pascual - 2016-07-15
    • Labels: --> taurus4
    • Category: taurus4 --> Jul16,