From 8996786331e30ba0703d2af8f7ebaf4d8b8c4af8 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 1 Jan 2024 17:43:12 +0100 Subject: [PATCH] Core: optimize DeprecateDict --- Utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Utils.py b/Utils.py index f6e4a9ab6052..b5e8c62e6daf 100644 --- a/Utils.py +++ b/Utils.py @@ -789,13 +789,13 @@ def __init__(self, message, error: bool = False) -> None: self.should_error = error super().__init__() - def __getitem__(self, item: Any) -> Any: - if self.should_error: - deprecate(self.log_message) - elif __debug__: + if __debug__: + def __getitem__(self, item: Any) -> Any: + if self.should_error: + deprecate(self.log_message) import warnings warnings.warn(self.log_message) - return super().__getitem__(item) + return super().__getitem__(item) def _extend_freeze_support() -> None: