Skip to content

add Enum to immutable types#5808

Merged
adhami3310 merged 1 commit into
reflex-dev:mainfrom
tim-haselhoff:immutable-enum
Sep 22, 2025
Merged

add Enum to immutable types#5808
adhami3310 merged 1 commit into
reflex-dev:mainfrom
tim-haselhoff:immutable-enum

Conversation

@tim-haselhoff

@tim-haselhoff tim-haselhoff commented Sep 22, 2025

Copy link
Copy Markdown
Contributor

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

After these steps, you're ready to open a pull request.

a. Give a descriptive title to your PR.
    Add enum to immutable types.

b. Describe your changes.
    Just adds Enum to IMMUTABLE_TYPES constant in utils/types.py because Enum is immutable in python.

c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR adds Python's Enum class to the IMMUTABLE_TYPES constant in reflex/utils/types.py. The change involves importing the Enum class and adding it to the tuple of immutable types that Reflex uses to classify values.

The modification is straightforward and addresses a gap in the type system. Python enums are inherently immutable - once created, enum members cannot be modified and are implemented as singletons. This immutability makes them suitable for inclusion in the IMMUTABLE_TYPES constant, which is used by the is_immutable() function to determine whether values can be safely treated as immutable.

This change fits naturally into Reflex's type classification system, which is used throughout the framework for state management, serialization, and other operations that need to distinguish between mutable and immutable data. The IMMUTABLE_TYPES constant already includes other immutable Python types like int, float, bool, str, bytes, frozenset, tuple, and type(None), so adding Enum completes this list with another fundamental immutable type.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects a simple, correct addition of a genuinely immutable type to an existing constant
  • No files require special attention

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me; @adhami3310 what do you think?

@codspeed-hq

codspeed-hq Bot commented Sep 22, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5808 will not alter performance

Comparing tim-haselhoff:immutable-enum (00608f7) with main (4468e14)

Summary

✅ 8 untouched

@adhami3310

Copy link
Copy Markdown
Member

some enums can be of mutable type, but it should be alr

@adhami3310 adhami3310 merged commit 1d9fee6 into reflex-dev:main Sep 22, 2025
41 checks passed
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