From af2da1ef9b9f7a5a19b6f77d432459afb699f408 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Tue, 8 Aug 2023 02:20:39 -0700 Subject: [PATCH] Fix incorrect passing of flags to re.sub --- CHANGES.rst | 2 ++ src/click/shell_completion.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 90faecc17..35a0ff428 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Version 8.1.7 Unreleased +- Fix issue with regex flags in shell completion. :issue:`2581` + Version 8.1.6 ------------- diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index 5de124702..9091f787e 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -230,7 +230,7 @@ def func_name(self) -> str: """The name of the shell function defined by the completion script. """ - safe_name = re.sub(r"\W*", "", self.prog_name.replace("-", "_"), re.ASCII) + safe_name = re.sub(r"\W*", "", self.prog_name.replace("-", "_"), flags=re.ASCII) return f"_{safe_name}_completion" def source_vars(self) -> t.Dict[str, t.Any]: