-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add explicit state name minification #6098
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
feat: Add explicit state name minification #6098
Conversation
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
Greptile OverviewGreptile SummaryThis PR introduces explicit state name minification via Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as User App Code
participant Meta as BaseStateMeta.__new__
participant Init as BaseState.__init_subclass__
participant Reg as _state_id_registry
participant GetName as BaseState.get_name()
participant Minify as _int_to_minified_name()
App->>Meta: Define class MyState(rx.State, state_id=42)
Meta->>Meta: Parse state_id parameter
Meta->>Meta: Set namespace["_mixin"] = False
Meta->>Init: Call __init_subclass__(state_id=42)
Init->>Init: Check if cls._mixin is True
Init->>Init: Set cls._state_id = 42
Init->>Reg: Check if state_id=42 exists
alt state_id already registered
Reg->>Init: Return existing class
Init->>Init: Validate not duplicate (same class OK)
else state_id not registered
Reg->>Init: Not found
end
Init->>Reg: Register state_id=42 -> MyState
Init->>Init: Validate module name
Init->>GetName: Call cls.get_name() for validation
GetName->>GetName: Get REFLEX_MINIFY_STATES mode
alt mode == DISABLED
GetName->>App: Return full_name (module___class)
else mode == ENABLED && cls._state_id is not None
GetName->>Minify: Call _int_to_minified_name(42)
Minify->>Minify: Convert 42 to base-54 ("q")
Minify->>GetName: Return "q"
GetName->>App: Return "q"
else mode == ENFORCE && cls._state_id is None
GetName->>App: Raise StateValueError
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
new alternative to #3728