diff --git a/aiida/engine/processes/workchains/workchain.py b/aiida/engine/processes/workchains/workchain.py index 9194c16c90..e6ca21a4b4 100644 --- a/aiida/engine/processes/workchains/workchain.py +++ b/aiida/engine/processes/workchains/workchain.py @@ -43,6 +43,9 @@ class WorkChainSpec(ProcessSpec, PlumpyWorkChainSpec): pass +MethodType = t.TypeVar('MethodType') + + class Protect(ProcessStateMachineMeta): """Metaclass that allows protecting class methods from being overridden by subclasses. @@ -84,14 +87,14 @@ def __is_final(mcs, method) -> bool: # pylint: disable=unused-private-member return False @classmethod - def final(mcs, method: t.Any): + def final(mcs, method: MethodType) -> MethodType: """Decorate a method with this method to protect it from being overridden. Adds the ``__SENTINEL`` object as the ``__final`` private attribute to the given ``method`` and wraps it in the ``typing.final`` decorator. The latter indicates to typing systems that it cannot be overridden in subclasses. """ - method.__final = mcs.__SENTINEL # pylint: disable=protected-access,unused-private-member + method.__final = mcs.__SENTINEL # type: ignore[attr-defined] # pylint: disable=protected-access,unused-private-member return t.final(method) @@ -365,7 +368,7 @@ def on_exiting(self) -> None: self.logger.exception('exception in _store_nodes called in on_exiting') @Protect.final - def on_wait(self, awaitables: t.Sequence[Awaitable]): + def on_wait(self, awaitables: t.Sequence[t.Awaitable]): """Entering the WAITING state.""" super().on_wait(awaitables) if self._awaitables: diff --git a/docs/source/nitpick-exceptions b/docs/source/nitpick-exceptions index 74ce91fbd3..76bb64c9a4 100644 --- a/docs/source/nitpick-exceptions +++ b/docs/source/nitpick-exceptions @@ -58,6 +58,7 @@ py:class aiida.orm.entitites.BackendEntityType py:class aiida.orm.groups.SelfType py:class aiida.orm.implementation.entitites.EntityType py:class aiida.engine.processes.functions.FunctionType +py:class aiida.engine.processes.workchains.workchain.MethodType py:class aiida.orm.entities.EntityType py:class aiida.orm.entities.BackendEntityType py:class aiida.orm.entities.CollectionType