[RFC] Indentation / import rules
John Arbash Meinel
john at arbash-meinel.com
Mon Jul 24 19:52:24 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robey Pointer wrote:
>
> On 24 Jul 2006, at 8:07, John Arbash Meinel wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Aaron Bentley wrote:
>>>
>>> I'm not sure I agree with that. Although PEP8 describes imports, it
>>> also describes long-line handling:
>>>
>>> The preferred way of wrapping long lines is by using Python's implied
>>> line continuation inside parentheses, brackets and braces.
>>>
>>> The examples it gives would favour:
>>>
>>> from bzrlib import (bar, foo, baz,
>>> llllllllllllllllong,
>>> short)
>
> That's the only one that doesn't look ugly to me.
>
>
>> Sure, but this conflicts with our desire to have good merging. PEP8
>> recommends adding multiple entries per line, but alphabetical sorting,
>> combined with one entry per line prevents conflicts.
>
> Do we really want to write bad code just to work around deficiencies in
> merging algorithms? IMHO the code should be clear and simple first,
> then we can worry about bogus conflicts later.
>
> I suspect anyone looking at that kind of conflict will immediately
> understand the issue and be able to fix it. Code that's formatted for
> computers instead of humans will be around causing pain for a much
> longer time.
>
> robey
It isn't as simple as you think. When there are 20 imports, and one
branch added 1 or 2, and your branch also adds a couple, then you have
to go one by one, and make sure none of them are missing. (Remember,
because of wrapping rules, if you overflow one line, you will
potentially modify all lines).
It really is a pain. And we have used this format for a lot of other
things. So I *do* think we want one entry per line. I think you are used
to the above format, but when you get used to it, the other really is
clearer.
And we already do one import per line with:
import os
import sys
import time
...
Rather than doing
import os, sys, time
One-per line is recommended by PEP8, they just don't really define 'from
x import y' notation as strictly.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFExRboJdeBCYSNAAMRAq/yAKDFaEUVhwhlD+j8PGj2yEyvxZOIaACguvHH
z1sqOsVK7CMfMhqKXZA/WbU=
=ujFJ
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list