pyapp-kit / superqt

Missing widgets and components for Qt-python
https://pyapp-kit.github.io/superqt/
BSD 3-Clause "New" or "Revised" License
210 stars 38 forks source link

feat: add support for flag enum #207

Closed Czaki closed 1 year ago

Czaki commented 1 year ago

As followup #205 I have checked that we do not have a test for another enum base class. So I prevent future failures, I added tests and spotted that flag support was not fully functional as it does not support element combinations.

Also add StrEnum test.

Summary by CodeRabbit

coderabbitai[bot] commented 1 year ago

Walkthrough

The changes primarily enhance the handling of enum classes in the QEnumComboBox class, adding support for Flag enums. New utility functions are introduced to generate a list of enum members and retrieve selected enum members. The test suite is expanded with new enum classes and test cases for the updated functionality.

Changes

File Summary
src/superqt/combobox/_enum_combobox.py Added support for Flag enums. Introduced utility functions _get_name_with_value and _get_enum_member_list. Updated setEnumClass and currentEnum methods to use these new functions.
tests/test_enum_comb_box.py Expanded test suite with new enum classes (IntFlag1, Flag1, IntFlag2, etc.) and added test cases for the updated QEnumComboBox functionality.

Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - Mention `@coderabbitai` in any *review comment* for bot assistance. - Note: Review comments are made on code diffs or files, not on the PR overview. ### Pause Incremental Reviews - Insert `@coderabbitai: ignore` in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 96.42% and project coverage change: +0.04% :tada:

Comparison is base (0b984c2) 87.34% compared to head (b57a37c) 87.38%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #207 +/- ## ========================================== + Coverage 87.34% 87.38% +0.04% ========================================== Files 45 45 Lines 3326 3346 +20 ========================================== + Hits 2905 2924 +19 - Misses 421 422 +1 ``` | [Files Changed](https://app.codecov.io/gh/pyapp-kit/superqt/pull/207?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit) | Coverage Δ | | |---|---|---| | [src/superqt/combobox/\_enum\_combobox.py](https://app.codecov.io/gh/pyapp-kit/superqt/pull/207?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3N1cGVycXQvY29tYm9ib3gvX2VudW1fY29tYm9ib3gucHk=) | `94.31% <96.42%> (+0.20%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tlambert03 commented 1 year ago

Thanks @Czaki

Looks like it needs updating for everything below 3.11

Czaki commented 1 year ago

Looks like it needs updating for everything below 3.11

Yes. I also hit problems as there was a bug in the new name mechanism in Python 3.11(.3).

As it is fixed in 3.11.5 then I left only the workaround code with a docstring explanation.