This is an automated email from the ASF dual-hosted git repository.
amoghdesai 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 a37109cba8 Speeding up regex match time for custom warnings (#40513)
a37109cba8 is described below
commit a37109cba8dd481b7cd675d51e43bbec3041da1e
Author: Amogh Desai <[email protected]>
AuthorDate: Mon Jul 1 17:41:08 2024 +0530
Speeding up regex match time for custom warnings (#40513)
---
airflow/settings.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/airflow/settings.py b/airflow/settings.py
index 617c98adff..dbe68bcb13 100644
--- a/airflow/settings.py
+++ b/airflow/settings.py
@@ -123,10 +123,12 @@ def _get_rich_console(file):
def custom_show_warning(message, category, filename, lineno, file=None,
line=None):
"""Print rich and visible warnings."""
# Delay imports until we need it
+ import re2
from rich.markup import escape
+ re2_escape_regex = re2.compile(r"(\\*)(\[[a-z#/@][^[]*?])").sub
msg = f"[bold]{line}" if line else f"[bold][yellow]{filename}:{lineno}"
- msg += f" {category.__name__}[/bold]: {escape(str(message))}[/yellow]"
+ msg += f" {category.__name__}[/bold]: {escape(str(message),
_escape=re2_escape_regex)}[/yellow]"
write_console = _get_rich_console(file or sys.stderr)
write_console.print(msg, soft_wrap=True)