From 81375e0d45dc7ce80bffd0dbad442e52b3a7e2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 11 Sep 2018 00:19:52 +0200 Subject: [PATCH] Use callable instead of instance of collections.Callable issue7666 review50571002 --- trytond/model/model.py | 3 +-- trytond/model/modelview.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/trytond/model/model.py b/trytond/model/model.py index 0b7fe370a8..99a2f50850 100644 --- a/trytond/model/model.py +++ b/trytond/model/model.py @@ -2,7 +2,6 @@ # this repository contains the full copyright notices and license terms. import copy -import collections from functools import total_ordering from trytond.model import fields @@ -77,7 +76,7 @@ class Model(WarningErrorMixin, URLMixin, PoolBase, metaclass=ModelMeta): fields_names = list(cls._fields.keys()) for field_name in fields_names: default_method = getattr(cls, 'default_%s' % field_name, False) - if isinstance(default_method, collections.Callable): + if callable(default_method): cls._defaults[field_name] = default_method for k in cls._defaults: diff --git a/trytond/model/modelview.py b/trytond/model/modelview.py index 27a1cc031f..ffd7dfc1a6 100644 --- a/trytond/model/modelview.py +++ b/trytond/model/modelview.py @@ -170,8 +170,7 @@ class ModelView(Model): meth_done = set() while meth_names: meth_name = meth_names.pop() - assert isinstance( - getattr(cls, meth_name), collections.Callable), \ + assert callable(getattr(cls, meth_name)), \ "%s.%s not callable" % (cls, meth_name) setattr(field, attribute, getattr(field, attribute) | methods['depends'][meth_name])