Re: [openstack-dev] [hacking] [style] multi-line imports PEP 0328

2015-08-27 Thread Ian Cordasco


On 8/25/15, 10:58, Clay Gerrard clay.gerr...@gmail.com wrote:



On Tue, Aug 25, 2015 at 8:45 AM, Kevin L. Mitchell
kevin.mitch...@rackspace.com wrote:

On Mon, 2015-08-24 at 22:53 -0700, Clay Gerrard wrote:
 So, I know that hacking has H301 (one import per line) - but say maybe
 you wanted to import *more* that one thing on a line (there's some
 exceptions right?  sqlalchemy migrations or something?)

There's never a need to import more than one thing per line given the
rule to only import modules, not objects.  While that is not currently
enforced by hacking, it is a strong style guideline.  (Exceptions for
things like sqlalchemy do exist, of course.)




Thank you for echoing my premise - H301 exists, but there are exceptions,
so...


On Mon, 2015-08-24 at 22:53 -0700, Clay Gerrard wrote:

Anyway - I'm sure there could be a pep8 plugin rule that enforces use of
parenthesis for multi line imports instead backslash line breaks [1] -
but would that be something that hacking would want to carry (since
 *most* of the time H301 would kick in first?) - or if not; is there a
way to plug it into pep8 outside of hacking without having to install
some random one-off extension for this one rule separately?



-Clay

So, I'm fairly certain that if it isn't on by default, that pep8 has a
check for lines that end in \. It will apply to import statements. That
said, by turning off the hacking checks around imports you lose some of
the consistency. So if you do that, consider flake8-import-order as a
plugin. It allows for multiple (non-module) imports on a line but insists
they be ordered appropriately and such.

Cheers,
Ian
Flake8 core developer, maintainer
Hacking core reviewer
pep8, pyflakes, mccabe, etc. maintainer/core developer/whatever

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [hacking] [style] multi-line imports PEP 0328

2015-08-25 Thread Kevin L. Mitchell
On Mon, 2015-08-24 at 22:53 -0700, Clay Gerrard wrote:
 So, I know that hacking has H301 (one import per line) - but say maybe
 you wanted to import *more* that one thing on a line (there's some
 exceptions right?  sqlalchemy migrations or something?)

There's never a need to import more than one thing per line given the
rule to only import modules, not objects.  While that is not currently
enforced by hacking, it is a strong style guideline.  (Exceptions for
things like sqlalchemy do exist, of course.)

-- 
Kevin L. Mitchell kevin.mitch...@rackspace.com
Rackspace


__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [hacking] [style] multi-line imports PEP 0328

2015-08-25 Thread Clay Gerrard
On Tue, Aug 25, 2015 at 8:45 AM, Kevin L. Mitchell 
kevin.mitch...@rackspace.com wrote:

 On Mon, 2015-08-24 at 22:53 -0700, Clay Gerrard wrote:
  So, I know that hacking has H301 (one import per line) - but say maybe
  you wanted to import *more* that one thing on a line (there's some
  exceptions right?  sqlalchemy migrations or something?)

 There's never a need to import more than one thing per line given the
 rule to only import modules, not objects.  While that is not currently
 enforced by hacking, it is a strong style guideline.  (Exceptions for
 things like sqlalchemy do exist, of course.)


Thank you for echoing my premise - H301 exists, but there are exceptions,
so...

On Mon, 2015-08-24 at 22:53 -0700, Clay Gerrard wrote:
Anyway - I'm sure there could be a pep8 plugin rule that enforces use of
parenthesis for multi line imports instead backslash line breaks [1] - but
would that be something that hacking would want to carry (since *most* of
the time H301 would kick in first?) - or if not; is there a way to plug it
into pep8 outside of hacking without having to install some random one-off
extension for this one rule separately?

-Clay
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


[openstack-dev] [hacking] [style] multi-line imports PEP 0328

2015-08-24 Thread Clay Gerrard
So, I know that hacking has H301 (one import per line) - but say maybe you
wanted to import *more* that one thing on a line (there's some exceptions
right?  sqlalchemy migrations or something?)

Anyway - I'm sure there could be a pep8 plugin rule that enforces use of
parenthesis for multi line imports instead backslash line breaks [1] - but
would that be something that hacking would want to carry (since *most* of
the time H301 would kick in first?) - or if not; is there a way to plug it
into pep8 outside of hacking without having to install some random one-off
extension for this one rule separately?

-Clay

1. https://www.python.org/dev/peps/pep-0328/#rationale-for-parentheses
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev