From e1c507c025c40424818a831a580daab48009d5fb Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 6 Apr 2020 15:18:54 -0400 Subject: [PATCH] plugin.core: Less introspective DIRECTIVE setting. Python 3.6 does not implement __class_getitem__, and because of that it's not possible to introspect when things like Hook[Transaction] are called. Sidestep the issue with a more explicit assignment. --- conservancy_beancount/plugin/core.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conservancy_beancount/plugin/core.py b/conservancy_beancount/plugin/core.py index 62df122..c9c8af1 100644 --- a/conservancy_beancount/plugin/core.py +++ b/conservancy_beancount/plugin/core.py @@ -69,12 +69,10 @@ class Hook(Generic[Entry], metaclass=abc.ABCMeta): @abc.abstractmethod def run(self, entry: Entry) -> errormod.Iter: ... - def __init_subclass__(cls) -> None: - # cls.__orig_bases__ comes from the ABCMeta metaclass - cls.DIRECTIVE = cls.__orig_bases__[0].__args__[0] # type:ignore[attr-defined] +class TransactionHook(Hook[Transaction]): + DIRECTIVE = Transaction -TransactionHook = Hook[Transaction] ### HELPER CLASSES