This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 13d2f4a7f1 Replace try/except/pass by contextlib.suppress in
ElasticSearch provider (#34251)
13d2f4a7f1 is described below
commit 13d2f4a7f1e347607122b65d5b45ef0504a8640b
Author: Hussein Awala <[email protected]>
AuthorDate: Sat Sep 9 23:33:38 2023 +0200
Replace try/except/pass by contextlib.suppress in ElasticSearch provider
(#34251)
---
airflow/providers/elasticsearch/log/es_task_handler.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/airflow/providers/elasticsearch/log/es_task_handler.py
b/airflow/providers/elasticsearch/log/es_task_handler.py
index 944fe88cf9..e227ca85ca 100644
--- a/airflow/providers/elasticsearch/log/es_task_handler.py
+++ b/airflow/providers/elasticsearch/log/es_task_handler.py
@@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations
+import contextlib
import inspect
import logging
import sys
@@ -322,12 +323,10 @@ class ElasticsearchTaskHandler(FileTaskHandler,
ExternalLoggingMixin, LoggingMix
# Using formatter._style.format makes it future proof i.e.
# if we change the formatter style from '%' to '{' or '$', this will
still work
if self.json_format:
- try:
+ with contextlib.suppress(Exception):
return self.formatter._style.format(
logging.makeLogRecord({**LOG_LINE_DEFAULTS,
**log_line.to_dict()})
)
- except Exception:
- pass
# Just a safe-guard to preserve backwards-compatibility
return log_line.message