ewels / rich-click

Format click help output nicely with rich.
https://ewels.github.io/rich-click/
MIT License
583 stars 33 forks source link

Invalid MRO when importing rich_click #195

Closed bhirsz closed 2 months ago

bhirsz commented 2 months ago

I've been using rich_click for quite a while - currently at 1.7.4. After bumping to 1.8 I'm getting errors with the following code:

import rich_click as click

error:

..\..\..\..\robotidy\cli.py:6: in <module>
    import rich_click as click
..\..\..\..\venv312\Lib\site-packages\rich_click\__init__.py:74: in <module>
    from rich_click.decorators import command as command
..\..\..\..\venv312\Lib\site-packages\rich_click\decorators.py:9: in <module>
    from rich_click.rich_command import RichCommand, RichGroup, RichMultiCommand  # noqa: F401
..\..\..\..\venv312\Lib\site-packages\rich_click\rich_command.py:301: in <module>
    class RichGroup(Group, RichMultiCommand):
E   TypeError: Cannot create a consistent method resolution
E   order (MRO) for bases Group, RichMultiCommand

It looks like both Group and RichMultiCommand inherits from Command class which causes issues with MRO.

dwreeves commented 2 months ago

Thanks for submitting an issue!

Which version of Python are you using? And which version of Click? Is there anything else in your configuration that may be of interest?

This is a weird issue, as it's not something we ever ran into when testing. I have a suspicion of what may be causing it.

bhirsz commented 2 months ago

Pythin 3.12. And I have just realized I'm using most recent, develop version of the Click(more recent than released 8.1.7). It may be the reason.

pon., 6 maj 2024, 17:40 użytkownik Daniel Reeves @.***> napisał:

Thanks for submitting an issue!

Which version of Python are you using? And which version of Click? Is there anything else in your configuration that may be of interest?

This is a weird issue, as it's not something we ever ran into when testing. I have a suspicion of what may be causing it.

— Reply to this email directly, view it on GitHub https://github.com/ewels/rich-click/issues/195#issuecomment-2096328273, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBDAYT3OAK2SW7WAOMRQL3ZA6P53AVCNFSM6AAAAABHIXBVSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGMZDQMRXGM . You are receiving this because you authored the thread.Message ID: @.***>

dwreeves commented 2 months ago

That's what I thought!

This is super helpful, I had a feeling the latest version of Click would cause issues, and I hadn't actually tested this part of the code. Thank you for unwittingly testing that for us 😅

I will have click~9 working (hopefully) as part of the 1.8.1 release. At least, this MRO issue will be resolved.

dwreeves commented 2 months ago

Github autoclosed this issue. I didn't fully test this (sorry, in a rush). I think it should be fixed. But let me know if it isn't.