Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with Click 7.x #16

Closed
Jorricks opened this issue Feb 21, 2022 · 3 comments
Closed

Not compatible with Click 7.x #16

Jorricks opened this issue Feb 21, 2022 · 3 comments

Comments

@Jorricks
Copy link
Contributor

Jorricks commented Feb 21, 2022

First of all, amazing project! Really loving the look & feel.
I think adoption by the community will be fast as the number of stars is already growing quickly.

I tried out the the package with Click 7.1.2 and received the following error:

  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Path/to/my/venv/lib/python3.8/site-packages/rich_click/rich_click.py", line 512, in main
    return super().main(*args, standalone_mode=False, **kwargs)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 781, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 700, in make_context
    self.parse_args(ctx, args)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 1212, in parse_args
    rest = Command.parse_args(self, ctx, args)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 1048, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 1630, in handle_parse_result
    value = invoke_param_callback(self.callback, ctx, self, value)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 123, in invoke_param_callback
    return callback(ctx, param, value)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 950, in show_help
    echo(ctx.get_help(), color=ctx.color)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 570, in get_help
    return self.command.get_help(self)
  File "/Path/to/my/venv/lib/python3.8/site-packages/click/core.py", line 975, in get_help
    self.format_help(ctx, formatter)
  File "/Path/to/my/venv/lib/python3.8/site-packages/rich_click/rich_click.py", line 520, in format_help
    rich_format_help(self, ctx, formatter)
  File "/Path/to/my/venv/lib/python3.8/site-packages/rich_click/rich_click.py", line 333, in rich_format_help
    isinstance(param.type, click.types._NumberRangeBase)
AttributeError: module 'click.types' has no attribute '_NumberRangeBase'

It appears this _NumberRangeBase comes from Click 8 onwards.
I think Click 8 has been around long enough for people to adopt it, and compatibility issues to upgrade from 7.x to 8.x are hardly present, it feels fine to me to keep the minimum requirement to be Click 8.0.0.
However, currently there is no lower bound, therefore I'd argue we should set it to click>8.0 in the requirements to make this more explicit.

@ewels
Copy link
Owner

ewels commented Feb 21, 2022

Thanks for the kind words! And thanks for testing this - I was thinking that I should try and figure out the lower bound, as it was bound to break at some point.

I might have a play to see if we can push compatibility lower (eg. this one looks like we could probably just capture the exception and ignore it..?), but I agree that it's a fairly low priority 👍🏻

@MatthiasZepper
Copy link

Can confirm, the NumberRangeBase class was introduced with PR 1303 for Click 8.0 and we encountered the same problem with the command line interface for the Data Delivery System.

Along this line, we also figured out that at least rich>=10.7.0 is required for rich-click... maybe an ever later version?

Traceback (most recent call last):
  File "/usr/local/bin/dds", line 5, in <module>
    from dds_cli.__main__ import dds_main
  File "/usr/local/lib/python3.8/site-packages/dds_cli/__main__.py", line 15, in <module>
    import rich_click as click
  File "/usr/local/lib/python3.8/site-packages/rich_click/__init__.py", line 12, in <module>
    from .rich_click import RichGroup
  File "/usr/local/lib/python3.8/site-packages/rich_click/rich_click.py", line 4, in <module>
    from rich.console import Console, group
ImportError: cannot import name 'group' from 'rich.console' (/usr/local/lib/python3.8/site-packages/rich/console.py)

This particular error is attributable to RenderGroup being renamed to Group with that version. (10.6.1 Commit -> PR1387 Version 10.7.0)

@ewels
Copy link
Owner

ewels commented Feb 28, 2022

Many thanks both - I have put in simple mechanisms to push support a little further back in history (should now work with click 7.0, rich 10.0) and then pinned the minimum versions for both packages.

Let me know if you find any other problems 👍🏻

Phil

@ewels ewels closed this as completed Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants