Skip to content

lib.enum: honor enum.nonmember. #1151

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

Merged
merged 1 commit into from
Feb 19, 2024
Merged

lib.enum: honor enum.nonmember. #1151

merged 1 commit into from
Feb 19, 2024

Conversation

kivikakk
Copy link
Contributor

Use _EnumDict._member_names to determine which members to consider. This way we don't need to redo sunder/dunder checks, and non-members are correctly excluded.

This is a defacto public API, given it remains usable from py3.8 until py3.12 inclusive. (_member_names changes from a list to a keys-only dict for performance reasons in py3.11, but they iterate the same.) In current Python main (i.e. what will most likely be 3.13), a member_names property is added which returns those keys.

@kivikakk kivikakk requested a review from whitequark as a code owner February 19, 2024 07:55
@kivikakk
Copy link
Contributor Author

Oh, nonmember itself is only a 3.11 thing! My bad. I'll make that check backwards-compatible.

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (890e099) 85.87% compared to head (1feb184) 85.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1151      +/-   ##
==========================================
- Coverage   85.87%   85.87%   -0.01%     
==========================================
  Files          43       43              
  Lines        8675     8674       -1     
  Branches     2065     2064       -1     
==========================================
- Hits         7450     7449       -1     
  Misses       1025     1025              
  Partials      200      200              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@whitequark whitequark added this to the 0.5 milestone Feb 19, 2024
@whitequark
Copy link
Member

Could you squash please? Also, let me know if you need a new 0.4.x series release; I've marked this PR as a backport but I only do actual backporting/releases when there is demand.

Use _EnumDict._member_names to determine which members to consider.
This way we don't need to redo sunder/dunder checks, and `nonmember`s
(introduced in py3.11) are correctly excluded.

This is a defacto public API, given it remains usable from py3.8
until py3.12 inclusive.  (_member_names changes from a list to a
keys-only dict for performance reasons in py3.11, but they iterate the
same.) In current Python main (i.e. what will most likely be 3.13), a
"member_names" property is added which returns those keys.
@kivikakk
Copy link
Contributor Author

Squashed!

And thanks re: the releases, understood! I'm living on main so no need from me at this stage. :)

@whitequark whitequark added this pull request to the merge queue Feb 19, 2024
Merged via the queue into amaranth-lang:main with commit c40cfc9 Feb 19, 2024
@kivikakk kivikakk deleted the enum-member-nonmember branch February 19, 2024 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants