From 4db7d7c31afbe1b49d843f68f3748660be3dc489 Mon Sep 17 00:00:00 2001 From: ATATC Date: Thu, 27 Jun 2024 15:07:13 +0800 Subject: [PATCH] Improved the efficiency of calling the super method. (#220) --- leads/callback.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/leads/callback.py b/leads/callback.py index b6d5233e..a3797071 100644 --- a/leads/callback.py +++ b/leads/callback.py @@ -15,8 +15,9 @@ def super(self, *args, **kwargs) -> None: Call the superior method if there is one. This must be called directly in the corresponding successor method. """ + if not self._chain: + return cf = _currentframe().f_back while (cn := cf.f_code.co_name) == "super": cf = cf.f_back - if self._chain: - getattr(self._chain, cn)(*args, **kwargs) + getattr(self._chain, cn)(*args, **kwargs)