Skip to content

NotImplementedError vs. abstract base classes #990

Open
@janden

Description

Currently we use NotImplementedError to signify methods that are to be overriden by child classes in our class hierarchy. An alternative is to use abstract base classes (ABCs). This also seems to be preferred by many in the community (such as here, here and here). Indeed, perhaps a more reasonable convention should be to use NotImplementedError would be for methods that are not yet implemented (see here). Some advantages:

  1. We can't get away without overriding since instantiation will error if the abstract methods are not overridden.
  2. Again, it's not always clear why the method's not implemented. Marking it as abstract provides the reason.
  3. All the raise NotImplementedError lines should technically be tested for (as they are currently missing from our code coverage), but that would be a little silly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions