From e47d5d98ccf281746c9876db3bc85ec430b07c58 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 11:12:57 +0000 Subject: [PATCH] Type Checking --- unittests/abstract_base/abstract_has_constraints.py | 2 +- unittests/abstract_base/checked_bad_param.py | 5 +++-- unittests/abstract_base/grandparent.py | 2 +- unittests/abstract_base/no_label.py | 2 +- unittests/abstract_base/unchecked_bad_param.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/unittests/abstract_base/abstract_has_constraints.py b/unittests/abstract_base/abstract_has_constraints.py index 1c422966..0744a058 100644 --- a/unittests/abstract_base/abstract_has_constraints.py +++ b/unittests/abstract_base/abstract_has_constraints.py @@ -36,7 +36,7 @@ def add_constraint(self, constraint: Any): @property @abstractmethod - def constraints(self): + def constraints(self) -> Any: """ An iterable of constraints :return: iterable of constraints diff --git a/unittests/abstract_base/checked_bad_param.py b/unittests/abstract_base/checked_bad_param.py index eb1d574f..7ef46279 100644 --- a/unittests/abstract_base/checked_bad_param.py +++ b/unittests/abstract_base/checked_bad_param.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Any from spinn_utilities.overrides import overrides from .abstract_grandparent import AbstractGrandParent from .abstract_has_constraints import AbstractHasConstraints @@ -25,9 +26,9 @@ def set_label(selfself, label): pass @overrides(AbstractHasConstraints.add_constraint) - def add_constraint(self, not_constraint): + def add_constraint(self, not_constraint: Any): raise NotImplementedError("We set our own constrainst") @overrides(AbstractHasConstraints.constraints) - def constraints(self): + def constraints(self) -> Any: return ["No night feeds", "No nappy changes"] diff --git a/unittests/abstract_base/grandparent.py b/unittests/abstract_base/grandparent.py index 99cc8392..6fd67428 100644 --- a/unittests/abstract_base/grandparent.py +++ b/unittests/abstract_base/grandparent.py @@ -31,5 +31,5 @@ def add_constraint(self, constraint: Any): raise NotImplementedError("We set our own constrainst") @overrides(AbstractHasConstraints.constraints) - def constraints(self): + def constraints(self) -> Any: return ["No night feeds", "No nappy changes"] diff --git a/unittests/abstract_base/no_label.py b/unittests/abstract_base/no_label.py index 3ac3bb23..ec90b657 100644 --- a/unittests/abstract_base/no_label.py +++ b/unittests/abstract_base/no_label.py @@ -28,5 +28,5 @@ def add_constraint(self, constraint: Any): raise NotImplementedError("We set our own constraints") @overrides(AbstractHasConstraints.constraints) - def constraints(self): + def constraints(self) -> Any: return ["No night feeds", "No nappy changes"] diff --git a/unittests/abstract_base/unchecked_bad_param.py b/unittests/abstract_base/unchecked_bad_param.py index fb11553a..f570fdba 100644 --- a/unittests/abstract_base/unchecked_bad_param.py +++ b/unittests/abstract_base/unchecked_bad_param.py @@ -30,5 +30,5 @@ def add_constraint(self, constraint: Any): raise NotImplementedError("We set our own constrainst") @overrides(AbstractHasConstraints.constraints) - def constraints(self): + def constraints(self) -> Any: return ["No night feeds", "No nappy changes"]