From 7b6eb3007c135cad4c7a873a92816bb540afb171 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 20 Dec 2016 12:14:52 -0800 Subject: Use abc module to signal abstract base classes The Completer class is abastract, and it's complete method is also abstract. Using ABCMeta achieve two thing, first it will cause an error if a developer doesn't overwrite the method in a subclass. And second that it tells the static analysis tools to ignore the unused arguments in the signature, since this is the definition of a signature, not an actual function. By the same logic addressbook.AddressBook, and account.Account have been extended to use ABCMeta as their metaclass and have had their abstract methods decorated with the abstract method attribute. --- alot/addressbook/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'alot/addressbook') diff --git a/alot/addressbook/__init__.py b/alot/addressbook/__init__.py index 6269f5d1..da0863f4 100644 --- a/alot/addressbook/__init__.py +++ b/alot/addressbook/__init__.py @@ -2,6 +2,7 @@ # This file is released under the GNU GPL, version 3 or a later revision. # For further details see the COPYING file import re +import abc class AddressbookError(Exception): @@ -17,9 +18,13 @@ class AddressBook(object): unspecified. See :class:`AbookAddressBook` and :class:`ExternalAddressbook` for implementations. """ + + __metaclass__ = abc.ABCMeta + def __init__(self, ignorecase=True): self.reflags = re.IGNORECASE if ignorecase else 0 + @abc.abstractmethod def get_contacts(self): """list all contacts tuples in this abook as (name, email) tuples""" return [] -- cgit v1.2.3