From d9db70cabdc9cb10cd5584464b8adb9a24545b92 Mon Sep 17 00:00:00 2001 From: Olivia Kinnear <51250849+superatomic@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:14:02 -0500 Subject: [PATCH] bash version support shows warning instead of error --- CHANGES.rst | 1 + src/click/shell_completion.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 35a0ff428..3662e5696 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Version 8.1.7 Unreleased - Fix issue with regex flags in shell completion. :issue:`2581` +- Bash version detection issues a warning instead of an error. :issue:`2574` Version 8.1.6 diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index 9091f787e..af4a57a23 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -301,7 +301,8 @@ class BashComplete(ShellComplete): name = "bash" source_template = _SOURCE_BASH - def _check_version(self) -> None: + @staticmethod + def _check_version() -> None: import subprocess output = subprocess.run( @@ -313,15 +314,17 @@ def _check_version(self) -> None: major, minor = match.groups() if major < "4" or major == "4" and minor < "4": - raise RuntimeError( + echo( _( "Shell completion is not supported for Bash" " versions older than 4.4." - ) + ), + err=True, ) else: - raise RuntimeError( - _("Couldn't detect Bash version, shell completion is not supported.") + echo( + _("Couldn't detect Bash version, shell completion is not supported."), + err=True, ) def source(self) -> str: