diff --git a/setup.py b/setup.py index 677bf15d..bf056de4 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,15 @@ setup( install_requires=["click>=7", "rich>=10.7.0", "importlib-metadata; python_version < '3.8'", "typing_extensions"], extras_require={ - "dev": ["pre-commit", "pytest", "flake8", "flake8-docstrings", "pytest-cov", "packaging", "types-setuptools"], + "dev": [ + "mypy", + "pre-commit", + "pytest", + "flake8", + "flake8-docstrings", + "pytest-cov", + "packaging", + "types-setuptools", + ], }, ) diff --git a/tests/fixtures/table_alignment.py b/tests/fixtures/table_alignment.py index 992c4464..aa4eecc4 100644 --- a/tests/fixtures/table_alignment.py +++ b/tests/fixtures/table_alignment.py @@ -1,5 +1,5 @@ import rich_click as click -from rich_click._compat_click import CLICK_IS_BEFORE_VERSION_8X +from rich_click._compat_click import CLICK_IS_BEFORE_VERSION_8X, CLICK_IS_VERSION_80 click.rich_click.STYLE_COMMANDS_TABLE_COLUMN_WIDTH_RATIO = (1, 2) @@ -98,7 +98,7 @@ def auth() -> None: print("Downloading") -if CLICK_IS_BEFORE_VERSION_8X: +if CLICK_IS_BEFORE_VERSION_8X and not CLICK_IS_VERSION_80: cmd_dec = cli.command() else: cmd_dec = cli.command diff --git a/tests/test_help.py b/tests/test_help.py index 25ca7fd5..f288827c 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -226,7 +226,21 @@ class ClickGroupWithRichCommandClass(click.Group): """ -group_help_output = """ +if rich_version.major == 12: + group_help_output = """ + Usage: cli [OPTIONS] COMMAND [ARGS]... + + Some help + ╔════════════════════════════════════════════════════════╗ + ║ Header ║ + ╚════════════════════════════════════════════════════════╝ + +╭─ Options ────────────────────────────────────────────────╮ +│ --help Show this message and exit. │ +╰──────────────────────────────────────────────────────────╯ +""" +else: + group_help_output = """ Usage: cli [OPTIONS] COMMAND [ARGS]... Some help @@ -244,10 +258,26 @@ class ClickGroupWithRichCommandClass(click.Group): @pytest.mark.parametrize( ("command_callable", "expected_command_type", "expected_help_output"), [ - pytest.param(lambda: command, RichCommand, command_help_output, id="command1"), + pytest.param( + lambda: command, + RichCommand, + command_help_output, + marks=pytest.mark.skipif( + click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0" + ), + id="command1", + ), pytest.param(lambda: command(), RichCommand, command_help_output, id="command2"), pytest.param(lambda: command("cli"), RichCommand, command_help_output, id="command3"), - pytest.param(lambda: group, RichGroup, group_help_output, id="group1"), + pytest.param( + lambda: group, + RichGroup, + group_help_output, + id="group1", + marks=pytest.mark.skipif( + click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0" + ), + ), pytest.param(lambda: group(), RichGroup, group_help_output, id="group2"), pytest.param(lambda: group("cli"), RichGroup, group_help_output, id="group3"), pytest.param(lambda: click.command(cls=RichCommand), RichCommand, command_help_output, id="click_command1"), @@ -261,6 +291,9 @@ class ClickGroupWithRichCommandClass(click.Group): RichCommand, command_help_output, id="RichGroup1", + marks=pytest.mark.skipif( + click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0" + ), ), pytest.param( lambda: RichGroup(name="grp", callback=lambda: None).command("cli"), @@ -273,6 +306,9 @@ class ClickGroupWithRichCommandClass(click.Group): RichCommand, command_help_output, id="ClickGroup1", + marks=pytest.mark.skipif( + click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0" + ), ), pytest.param( lambda: ClickGroupWithRichCommandClass(name="grp", callback=lambda: None).command("cli"), @@ -285,6 +321,9 @@ class ClickGroupWithRichCommandClass(click.Group): RichGroup, group_help_output, id="ClickGroup3", + marks=pytest.mark.skipif( + click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0" + ), ), pytest.param( lambda: ClickGroupWithRichCommandClass(name="grp", callback=lambda: None).group("cli"),