[openstack-dev] Dropping or weakening the 'only import modules' style guideline - H302

Alex Gaynor alex.gaynor at gmail.com
Tue Aug 6 02:31:36 UTC 2013


I'd favor weakening or removing this requirement. Besides google I've never
seen any other python project which enforced this standard, and I think
it's a very weak heuristic for readability.

Alex


On Mon, Aug 5, 2013 at 7:26 PM, Robert Collins <robertc at robertcollins.net>wrote:

> I wanted to get a temperature reading from everyone on this style
> guideline.
>
> My view on it is that it's a useful heuristic but shouldn't be a
> golden rule applied everywhere. Things like matches are designed to be
> used as a dsl:
>     self.assertThat(foo, Or(Equals("1"), Equals("2")))
>
> rather than what H302 enforces:
>     self.assertThat(foo, matchers.Or(matchers.Equals("1"),
> matchers.Equals("2")))
>
> Further, conflicting module names become harder to manage, when one
> could import just the thing.
>
> Some arguments for requiring imports of modules:
>  - makes the source of symbols obvious
>    - Actually, it has no impact on that as the import is still present
> and clear in the file. import * would obfuscate things, but I'm not
> arguing for that.
>    - and package/module names can (and are!) still ambiguous. Like
> 'test.' - whats that? -> consult the imports.
>  - makes mocking more reliable
>    - This is arguably the case, but it's a mirage: it isn't a complete
> solution because modules still need to be mocked at every place they
> are dereferenced : only import modules helps to the extent that one
> never mocks modules. Either way this failure mode of mocking is
> usually very obvious IME : but keeping the rule as a recommendation,
> *particularly* when crossing layers to static resources is a good
> idea.
>  - It's in the Google Python style guide
> (
> http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Imports#Imports
> )
>    - shrug :)
>
> What I'd like us to do is weaken it from a MUST to a MAY, unless noone
> cares about it at all, in which case lets just turn it off entirely.
>
> -Rob
>
> --
> Robert Collins <rbtcollins at hp.com>
> Distinguished Technologist
> HP Converged Cloud
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130805/203e7dd2/attachment.html>


More information about the OpenStack-dev mailing list