From 6a2f54322231c07cbb9796fae127402c06cea0d2 Mon Sep 17 00:00:00 2001 From: oswaldohernandez Date: Tue, 3 Sep 2024 13:32:19 -0600 Subject: [PATCH] fix: remove redundant exception and str checking --- src/pythonjsonlogger/jsonlogger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pythonjsonlogger/jsonlogger.py b/src/pythonjsonlogger/jsonlogger.py index 519a64d..4056228 100644 --- a/src/pythonjsonlogger/jsonlogger.py +++ b/src/pythonjsonlogger/jsonlogger.py @@ -82,7 +82,7 @@ def default(self, obj): elif istraceback(obj): return "".join(traceback.format_tb(obj)).strip() - elif type(obj) == Exception or isinstance(obj, Exception) or type(obj) == type: + elif isinstance(obj, Exception): return str(obj) try: @@ -222,7 +222,7 @@ def add_fields( ) if self.timestamp: - key = self.timestamp if type(self.timestamp) == str else "timestamp" + key = self.timestamp if isinstance(self.timestamp, str) else "timestamp" log_record[key] = datetime.fromtimestamp(record.created, tz=timezone.utc) self._perform_rename_log_fields(log_record)