[openstack-dev] [Horizon] HACKING.rst and import standards

Tatiana Mazur tmazur at mirantis.com
Mon Jun 10 11:44:00 UTC 2013


 Hi everyone,

Thanks for your responses, I'm starting work on alphabetic one import per
line now (https://blueprints.launchpad.net/horizon/+spec/hacking). Thanks
Joe Gordon for tox.ini !

Kind regards,
Tatiana

On 06/08/2013 03:11 AM, Gabriel Hurley wrote:

 A topic not discussed is module-level import vs object-level import.
While other core projects only use module-level import, Horizon uses both
and object-level imports are widely used like below.

 Yep, I had left that one out on purpose for a few reasons:

1. I (personally) find this to be a rule based more on dogma than
actual improvement to readability/code quality. It often results in
having to alias modules to shorter names, etc. to try and keep line
lengths down, or having to type the name of module before a function
every time you want to use it. I understand the arguments in favor of
it, but it doesn't do much for me.

2. It would require a tremendous amount of rewriting (far more so than
any of the fixes I *would* like to see turned on) for no practical
gain.

3.  It's mostly a matter of taste. To that point, PEP8 indicates that
both are completely valid and acceptable styles. Strictly enforcing it
where it's actively making things less readable or less convenient is
precisely the warning of "A Foolish Consistency is the Hobgoblin of
Little Minds."

4.  Alphabetical one-import-per-line importing fixes most of the
practical issues that module-level-only importing is supposed to fix,
and most modern editors make it trivial to see where something was
defined so the "know where things are defined" argument doesn't hold
much weight.

If the rest of the contributor-base for Horizon strongly prefers that
we enforce module-level-only importing then I am willing to listen,
but without strong reason to do so I think we have much more fruitful
things we could be working on.

That's mostly my personal two cents, and should not be taken as a
commandment or decision upon the project.

All the best,

    - Gabriel

_______________________________________________
OpenStack-dev mailing
listOpenStack-dev at lists.openstack.orghttp://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130610/b749e81f/attachment.html>


More information about the OpenStack-dev mailing list