[openstack-dev] [hacking] proposed rules drop for 1.0

Matthew Treinish mtreinish at kortar.org
Tue Dec 9 16:41:06 UTC 2014


On Tue, Dec 09, 2014 at 10:15:34AM -0600, Brian Curtin wrote:
> On Tue, Dec 9, 2014 at 9:05 AM, Sean Dague <sean at dague.net> wrote:
> > - [H305 H306 H307] Organize your imports according to the `Import order
> >   template`_ and `Real-world Import Order Examples`_ below.
> >
> > I think these remain reasonable guidelines, but H302 is exceptionally
> > tricky to get right, and we keep not getting it right.
> >
> > H305-307 are actually impossible to get right. Things come in and out of
> > stdlib in python all the time.
> 
> Do you have concrete examples of where this has been an issue? Modules
> are only added roughly every 18 months and only on the 3.x line as of
> the middle of 2010 when 2.7.0 was released. Nothing should have left
> the 2.x line within that time as well, and I don't recall anything
> having completed a deprecation cycle on the 3.x side.
> 

I don't have any examples of stdlib removals (and there may not be any) but that
isn't the only issue with the import grouping rules. The reverse will also
cause issues, adding a library to stdlib which was previously a third-party
module. The best example I've found is pathlib which was added to stdlib in 3.4:

https://docs.python.org/3/library/pathlib.html

but a third-party module on all the previous releases:

https://pypi.python.org/pypi/pathlib

So, the hacking rule will behave differently depending on which version of
python you're running with. There really isn't a way around that, if the rule
can't behave consistently and enforce the same behavior between releases we
shouldn't be using it. Especially as things are trying to migrate to use python
3 where possible.

I've seen proposals to hard code the list of stdlib in the rule to a specific
python version which would make the behavior consistent, but I very much opposed
to that because it means we're not actually enforcing the correct thing which I
think is as big an issue. We don't want the hacking checks to error out and say
that pathlib is a 3rd party module even if we're running it on python 3.4, that
would just be very confusing.

The middle ground I proposed was to not differentiate the third-party and stdlib
import groups and just check local project's import grouping against the others.
This would make the behavior consistent between python versions and still
provide some useful feedback. But if the consensus is to just remove the rules
I'm fine with that too.


-Matt Treinish
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141209/60ee0b41/attachment.pgp>


More information about the OpenStack-dev mailing list