Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
ff564922 by Cédric Krier at 2023-01-03T18:50:28+01:00
Add error message to Pool asserts
- - - - -


1 changed file:

- trytond/trytond/pool.py


Changes:

=====================================
trytond/trytond/pool.py
=====================================
@@ -84,6 +84,7 @@
         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]
@@ -88,7 +89,8 @@
         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 @@
                         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)



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/ff5649227ea488a42679033dcae025551df2be4d

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/ff5649227ea488a42679033dcae025551df2be4d
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to