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 1/2] 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]: From d69d2106d821c43507829100f36774bbb7a1092b Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 17 Aug 2023 10:03:11 -0700 Subject: [PATCH 2/2] fix flake8 finding --- src/click/_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/click/_compat.py b/src/click/_compat.py index 9153d150c..23f886659 100644 --- a/src/click/_compat.py +++ b/src/click/_compat.py @@ -516,7 +516,7 @@ def _get_argv_encoding() -> str: _ansi_stream_wrappers: t.MutableMapping[t.TextIO, t.TextIO] = WeakKeyDictionary() - def auto_wrap_for_ansi( + def auto_wrap_for_ansi( # noqa: F811 stream: t.TextIO, color: t.Optional[bool] = None ) -> t.TextIO: """Support ANSI color and style codes on Windows by wrapping a