From 95a480fd9394376fb0a0348849600f7c58a5a695 Mon Sep 17 00:00:00 2001 From: dwreeves Date: Sun, 9 Jun 2024 22:28:08 -0400 Subject: [PATCH] fix more bugs --- CHANGELOG.md | 5 +++++ src/rich_click/__init__.py | 2 +- src/rich_click/rich_help_configuration.py | 15 ++++++++------- src/rich_click/rich_help_rendering.py | 4 ++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b850da7..d8f42e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Version 1.8.3 (2023-06-09) + +- Support `{cmd}` as an option/command group key when `python -m {cmd}` is the command_path. +- Fix yet another deprecation warning issue. (Sorry, sorry.) + ## Version 1.8.2 (2023-05-14) - Fix another deprecation warning issue. diff --git a/src/rich_click/__init__.py b/src/rich_click/__init__.py index bd9d193..e50703e 100644 --- a/src/rich_click/__init__.py +++ b/src/rich_click/__init__.py @@ -6,7 +6,7 @@ customisation required. """ -__version__ = "1.8.2" +__version__ = "1.8.3" # Import the entire click API here. # We need to manually import these instead of `from click import *` to force diff --git a/src/rich_click/rich_help_configuration.py b/src/rich_click/rich_help_configuration.py index 0e0afae..002f858 100644 --- a/src/rich_click/rich_help_configuration.py +++ b/src/rich_click/rich_help_configuration.py @@ -238,13 +238,14 @@ class OptionHighlighter(RegexHighlighter): r"(?P<[^>]+>)", ] - import warnings - - warnings.warn( - "OptionHighlighter is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) + # todo: fix + # import warnings + # + # warnings.warn( + # "OptionHighlighter is deprecated and will be removed in a future version.", + # DeprecationWarning, + # stacklevel=2, + # ) globals()["OptionHighlighter"] = OptionHighlighter diff --git a/src/rich_click/rich_help_rendering.py b/src/rich_click/rich_help_rendering.py index aaf44c9..6543102 100644 --- a/src/rich_click/rich_help_rendering.py +++ b/src/rich_click/rich_help_rendering.py @@ -388,6 +388,10 @@ def _resolve_groups( paths = [cmd_name, ctx.command_path] else: paths = [cmd_name] + # Also handle 'python -m foo' when the user specifies a key of 'foo': + if ctx.command_path.startswith("python -m "): + extra = ctx.command_path.replace("python -m ", "", 1) + paths.append(extra) final_groups_list: List[GroupType] = [] # Assign wildcards, but make sure we do not overwrite anything already defined.