Use abc instead of NotImplementedError

Bug #1346797 reported by Marc Koderer on 2014-07-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Undecided
Marc Koderer
OpenStack Heat
Fix Released
Low
Daniel Gonzalez Nothnagel
tempest
Low
Danny Al-Gaaf

Bug Description

Problem:
=======

Use of abc for abstract classes is better than raising NotImplementedError exceptions due to various reasons (see [1], [2]).
Usage of abc will fail fast if a subclass doesn't implement the full interface.
This should be the preferred mechanism to define common interfaces.

References:
=========

[1]: http://legacy.python.org/dev/peps/pep-3119/
[2]: dbader.org/blog/abstract-base-classes-in-python

Marc Koderer (m-koderer) on 2014-07-22
Changed in tempest:
assignee: nobody → Marc Koderer (m-koderer)
Marc Koderer (m-koderer) on 2014-07-22
Changed in cinder:
assignee: nobody → Marc Koderer (m-koderer)
Changed in cinder:
status: New → In Progress
Changed in tempest:
status: New → In Progress

Reviewed: https://review.openstack.org/108606
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=235e4f53ee05dc4c4226bd7b327068ed031e76c5
Submitter: Jenkins
Branch: master

commit 235e4f53ee05dc4c4226bd7b327068ed031e76c5
Author: Marc Koderer <email address hidden>
Date: Tue Jul 22 10:15:08 2014 +0200

    Use python abc in auth class

    Instead of using NotImplementedError the abc class has the advantage
    that it fails faster if a class doesn't implement the needed interface.
    Adapt unit test and test class.

    Change-Id: Ide914a4bb577a28a3d202cbf088c404323a29b21
    Partial-Bug: #1346797

Marc Koderer (m-koderer) on 2014-08-13
Changed in tempest:
importance: Undecided → Low

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

Changed in tempest:
assignee: Marc Koderer (m-koderer) → Danny Al-Gaaf (danny-al-gaaf)

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

Reviewed: https://review.openstack.org/108659
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=64f6bebc6623a0e48dde3bef38390460728ea91e
Submitter: Jenkins
Branch: master

commit 64f6bebc6623a0e48dde3bef38390460728ea91e
Author: Marc Koderer <email address hidden>
Date: Tue Jul 22 13:53:45 2014 +0200

    Use abstract class for the backup driver interface

    Instead of using NotImplementedError exceptions to define the interface
    it's better to use python abc class [1]. The advantage that it fails
    faster if a class doesn't implement the needed interface.
    See also [2].

    [1]: http://legacy.python.org/dev/peps/pep-3119/
    [2]: http://dbader.org/blog/abstract-base-classes-in-python

    Change-Id: I625a73f70ac5c6ca68ee38a70c98d999454a817e
    Partial-Bug: #1346797

Reviewed: https://review.openstack.org/113850
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=d1809674a7495318e455542a58ea832e71528c86
Submitter: Jenkins
Branch: master

commit d1809674a7495318e455542a58ea832e71528c86
Author: Danny Al-Gaaf <email address hidden>
Date: Wed Aug 13 13:12:19 2014 +0200

    Use python abc in DeletableResource class

    Fix pylint error about NotImplemented raised instead of
    NotImplementedError.

    Use the abc class instead of NotImplementedError.

    Partial-Bug: #1346797

    Change-Id: I50df1edf5c6b5c7a5c385a6389da97ffffea4d07
    Signed-off-by: Danny Al-Gaaf <email address hidden>

Reviewed: https://review.openstack.org/113820
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=fd247f592229984bccac2600483058750d0024fd
Submitter: Jenkins
Branch: master

commit fd247f592229984bccac2600483058750d0024fd
Author: Danny Al-Gaaf <email address hidden>
Date: Wed Aug 13 11:25:24 2014 +0200

    Use python abc in StressAction class

    Fix pylint error about NotImplemented raised instead of
    NotImplementedError.

    Use the abc class instead of NotImplementedError.

    Partial-Bug: #1346797

    Change-Id: Ia9a75a53f68c28594654a07146a2a30c1ae3c412
    Signed-off-by: Danny Al-Gaaf <email address hidden>

Changed in heat:
assignee: nobody → Daniel Gonzalez Nothnagel (dgonzalez)

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

Changed in heat:
status: New → In Progress

Reviewed: https://review.openstack.org/153744
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=d6db8025a3c0b1997b3035baaef6fd2d22bebc6c
Submitter: Jenkins
Branch: master

commit d6db8025a3c0b1997b3035baaef6fd2d22bebc6c
Author: Daniel Gonzalez <email address hidden>
Date: Sat Feb 7 01:42:49 2015 +0100

    Use python abc for abstract classes

    Instead of raising NotImplementedErrors in abstract methods, mark them as
    abstract using python abc class [1].
    See also [2]

    [1]: http://legacy.python.org/dev/peps/pep-3119/
    [2]: http://dbader.org/blog/abstract-base-classes-in-python

    Change-Id: Ief9eefc2ae87526248b91abd04b6e62ad94fbf35
    Partial-Bug: #1346797

Yaroslav Lobankov (ylobankov) wrote :

The corresponding change for Tempest was merged (Aug 22, 2014), but the current status of the bug is "In progress". So it looks like we should move the status for Tempest to "Fix released".

Changed in tempest:
status: In Progress → Fix Released
Changed in heat:
importance: Undecided → Low
status: In Progress → Triaged

As the changes has been merged in GIT changing the status.

Changed in heat:
status: Triaged → Fix Released
Changed in cinder:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers