Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long line break on slice notation #281

Open
tobixx opened this issue Nov 4, 2016 · 7 comments
Open

Long line break on slice notation #281

tobixx opened this issue Nov 4, 2016 · 7 comments

Comments

@tobixx
Copy link

tobixx commented Nov 4, 2016

In this concrete example it is a line break in middle of accessing an dictionary member,like general: dict_object[key] turns into dict_object[\nkey]

  1. not related
  2. autopep8 2.0a0
  3. 2.0.0
  4. Python 2.7.6
  5. Linux xxx 3.19.0-71-generic problem with open bracket #79~14.04.1-Ubuntu SMP Sat Oct 8 20:07:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  6. Exmaple input:
GYakymOSMW=1
GYakymOSME=1
GYakymOSMJ=1
GYakymOSMA=1
GYakymOSMr=1
GYakymOSMw=1
GYakymOSMU=1
GYakymOSMq=1
GYakymOSMH=1
GYakymOSMl=1
GYakymOSMz=GYakymOSME
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,filterAirlines=GYakymOSME)
  1. --select=E501
  2. Expected output: any candidate but the first one:
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw[
                      'abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,
                      GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,
                      GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(
    GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],
                      GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,
                      GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,
                      GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,
                      GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,
                      GYakymOSMl,svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,
                      svygreNveyvarf=GYakymOSME)
-------------------------------------------------------------------------------
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)

Personally I would prefer the even length distributed parameter solution (nr. 6), but not nr.4 - just saying. Anyway this is just an opinion . But the first selection is a no-go. Maybe an option for an preferred user strategie would be a good idea - but hard. At least a prevention of the shown break. Nice would be something like "filLinesfromBeginning" because as shown the order prefers "fillLinesAtTheEnd".
9. yes

@spaceone
Copy link
Contributor

spaceone commented Nov 4, 2016

In my opinion the output should be:

GYakymOSMc = GYakymOSMW(
    GYakymOSMJ,
    GYakymOSMA,
    GYakymOSMr,
    GYakymOSMw['abc'],
    GYakymOSMU,
    GYakymOSMq,
    GYakymOSMH,
    GYakymOSMl,
    svygreNveyvarf=GYakymOSME
)

@tobixx
Copy link
Author

tobixx commented Nov 4, 2016

@spaceone you can have it even now with more aggressive settings and/or experimental - so your option is already there.

@spaceone
Copy link
Contributor

spaceone commented Nov 4, 2016

@tobixx Ah really? Too bad, that I didn't knew this a week ago. I autopep8'ed about 30000 files.

@tobixx
Copy link
Author

tobixx commented Nov 4, 2016

@spaceone yes - one additionaly '-a' is already enough. (just tried it)

@tobixx
Copy link
Author

tobixx commented Nov 4, 2016

After looked into 139 test for the E501 : ignore all my nice to have wishes ^^

This was referenced Nov 7, 2016
@spaceone
Copy link
Contributor

spaceone commented Nov 7, 2016

@tobixx I don't get the option with aggressive/experimental to work:

>>> print autopep8.fix_code("""res = ldap_machine_read.search(base=ldap_position.getDn(),\n\tfilter=filter,\n\tattr=['cn', 'associatedDomain'])\n""", options={'aggressive': 9, 'experimental': True})

produces

res = ldap_machine_read.search(base=ldap_position.getDn(),
                               filter=filter,
                               attr=['cn', 'associatedDomain'])

What I want is:

res = ldap_machine_read.search(
    base=ldap_position.getDn(),
    filter=filter,
    attr=['cn', 'associatedDomain']
)

Do you think there is a chance to get this output?

@tobixx
Copy link
Author

tobixx commented Nov 7, 2016

@spaceone At least not in the place I modified it. There only a rank is determined where to break a long line, but in your case there is really nothing to fix (in terms of pep8) anything at all - because you don't even hit the trigger - your line is already short enough. Even if it would kick in for your example, there is nowhere your most liked solution calculated as a candidate. The nearest solution would also break up the list in it - which is probably not the thing you want. This would be probably fixable, but in the end we again talk about a style according to an personal opinion instead of only fixing pep8 stuff. Well, I also want it, but this seems to be absolutely overkill for this tool - at least the name then does not cover it anymore ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants