From aa0d38bf02d34a6df788477da30eac6e58ffbda5 Mon Sep 17 00:00:00 2001 From: Maarten Breddels Date: Mon, 12 Dec 2022 17:08:33 +0100 Subject: [PATCH] fix: some descriptors raise AttributeError (#812) Regression, noticed in https://github.com/ipython/traitlets/pull/777#issuecomment-1344691036 --- traitlets/traitlets.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py index 73133842..6f03c257 100644 --- a/traitlets/traitlets.py +++ b/traitlets/traitlets.py @@ -1006,7 +1006,13 @@ def setup_class(cls, classdict): # noqa mro = cls.mro() for name in dir(cls): - value = getattr(cls, name) + # Some descriptors raise AttributeError like zope.interface's + # __provides__ attributes even though they exist. This causes + # AttributeErrors even though they are listed in dir(cls). + try: + value = getattr(cls, name) + except AttributeError: + continue if isinstance(value, TraitType): cls._traits[name] = value trait = value