From 5188a2ee5189dcbdf08deed74faf501cc3ac301a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 3 Jan 2023 18:50:28 +0100 Subject: [PATCH] Add error message to Pool asserts --- trytond/trytond/pool.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/trytond/trytond/pool.py b/trytond/trytond/pool.py index 6b52edb4a2..8d4c6af217 100644 --- a/trytond/trytond/pool.py +++ b/trytond/trytond/pool.py @@ -84,11 +84,13 @@ class Pool(object): module = kwargs['module'] type_ = kwargs['type_'] depends = set(kwargs.get('depends', [])) - assert type_ in ('model', 'report', 'wizard') + assert type_ in {'model', 'report', 'wizard'}, ( + f"{type_} is not a valid type_") for cls in classes: mpool = Pool.classes[type_][module] - assert cls not in mpool, cls - assert issubclass(cls.__class__, PoolMeta), cls + assert cls not in mpool, f"{cls} is already registered" + assert issubclass(cls.__class__, PoolMeta), ( + f"{cls} is missing metaclass {PoolMeta}") mpool[cls] = depends @staticmethod @@ -233,7 +235,8 @@ class Pool(object): cls.__name__, (cls, previous_cls), {'__slots__': ()}) except KeyError: pass - assert issubclass(cls, PoolBase), cls + assert issubclass(cls, PoolBase), ( + f"{cls} is not a subclass of {PoolBase}") self.add(cls, type=type_) classes[type_].append(cls) self._modules.append(module)