Skip to content

Conversation

@federicobond
Copy link
Member

@federicobond federicobond commented Dec 7, 2025

Copies the behavior of Python 3.11+ StrEnum by implementing __str__.

This is to ensure the value of str(Reason.DEFAULT) or str(ErrorCode.GENERAL) remains the same regardless of Python version.

@federicobond federicobond requested review from a team as code owners December 7, 2025 01:06
@gemini-code-assist
Copy link

Summary of Changes

Hello @federicobond, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request standardizes the string conversion behavior for StrEnum instances by implementing the __str__ method in the backported StrEnum class. The primary goal is to ensure that str(enum_member) consistently returns the enum member's value, aligning with Python 3.11+ behavior and providing a uniform experience regardless of the Python runtime version. This change is supported by new tests confirming the expected string output for relevant enum types.

Highlights

  • StrEnum Backport Enhancement: The StrEnum backport for Python versions prior to 3.11 now includes an explicit __str__ method. This change ensures that calling str() on a StrEnum member consistently returns its value attribute, mirroring the behavior of the standard library's StrEnum in Python 3.11 and later.
  • Consistent String Representation: This modification guarantees that the string representation of StrEnum instances, such as Reason.DEFAULT or ErrorCode.GENERAL, remains uniform across different Python versions, preventing potential inconsistencies in applications that rely on these string conversions.
  • New Test Coverage: New unit tests have been added to verify the correct __str__ behavior for ErrorCode and Reason enums, ensuring the intended functionality is maintained.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.84%. Comparing base (8fdd784) to head (5588df0).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
openfeature/_backports/strenum.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #552      +/-   ##
==========================================
- Coverage   97.89%   97.84%   -0.05%     
==========================================
  Files          39       40       +1     
  Lines        1849     1855       +6     
==========================================
+ Hits         1810     1815       +5     
- Misses         39       40       +1     
Flag Coverage Δ
unittests 97.84% <71.42%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gemini-code-assist
Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@aepfli
Copy link
Member

aepfli commented Dec 7, 2025

/Gemini review

@gemini-code-assist
Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@federicobond federicobond merged commit 63db4d7 into main Dec 8, 2025
15 of 17 checks passed
@federicobond federicobond deleted the fix-strenum branch December 9, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants