PEP8 horizon cleanup

Bug #911531 reported by Zhongyue Luo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Zhongyue Luo

Bug Description

The None, True, and False values are singletons.

All variable *comparisons* to singletons should use 'is' or 'is not'.
All variable *evaluations* to boolean should use 'if' or 'if not'.
All Object type comparisons should use isinstance() instead of comparing types directly

Programming Recommendations
    - Comparisons to singletons like None should always be done with
      'is' or 'is not', never the equality operators.

    - Don't compare boolean values to True or False using ==
        Yes: if greeting:
        No: if greeting == True:
        Worse: if greeting is True:

    - Object type comparisons should always use isinstance() instead
      of comparing types directly.

        Yes: if isinstance(obj, int):

        No: if type(obj) is type(1):

      When checking if an object is a string, keep in mind that it might be a
      unicode string too! In Python 2.3, str and unicode have a common base
      class, basestring, so you can do:

        if isinstance(obj, basestring):

Zhongyue Luo (zyluo)
Changed in horizon:
assignee: nobody → LZY (lzyeval)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/2769

Changed in horizon:
status: New → In Progress
Zhongyue Luo (zyluo)
summary: - PEP8 cleanup
+ PEP8 horizon cleanup
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/2769
Committed: http://github.com/openstack/horizon/commit/cf088fbb72094b8b8e22b3dfbd54b162fef4906d
Submitter: Jenkins
Branch: master

commit cf088fbb72094b8b8e22b3dfbd54b162fef4906d
Author: lzyeval <email address hidden>
Date: Wed Jan 4 08:49:49 2012 +0800

    PEP8 cleanup

    Fixes bug #911531

    The None, True, and False values are singletons.

    All variable *comparisons* to singletons should use 'is' or 'is not'.
    All variable *evaluations* to boolean should use 'if' or 'if not'.
    All Object type comparisons should use isinstance() instead of comparing types directly

    Change-Id: Ie1b3e18bad22a2baeb79d50928267a4cac0a55e4

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
milestone: none → essex-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: essex-3 → 2012.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.