Skip to content

deprecate state_auto_setters=True#5739

Merged
adhami3310 merged 3 commits intomainfrom
deprecate-state_auto_setters
Aug 29, 2025
Merged

deprecate state_auto_setters=True#5739
adhami3310 merged 3 commits intomainfrom
deprecate-state_auto_setters

Conversation

@adhami3310
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR implements a deprecation strategy for the state_auto_setters configuration option, which currently defaults to True and automatically generates setter methods for state variables. The changes introduce a three-phase deprecation approach:

  1. Configuration Change: The state_auto_setters field in reflex/config.py is changed from bool = True to bool | None = None, making None the new default value.

  2. Logic Update: In reflex/state.py, the condition for creating automatic setters is updated from get_config().state_auto_setters to get_config().state_auto_setters is not False. This ensures that when the config is None (the new default), setters are still created to maintain backward compatibility.

  3. Deprecation Warning: In reflex/vars/base.py, a new deprecation warning is added to the _get_setter method. When state_auto_setters is None (indicating users haven't explicitly configured it), the system issues a warning indicating that the default behavior will change from True to False in version 0.9.0.

  4. Enhanced Frame Detection: The deprecation warning system in reflex/utils/console.py is improved with better frame detection logic to more accurately identify user code vs framework code when issuing warnings. This includes excluding Python standard library modules and additional third-party frameworks from the warning context.

This deprecation follows standard software engineering practices: warn users about the upcoming change while maintaining current functionality, giving them time to either explicitly set state_auto_setters=True to keep current behavior or state_auto_setters=False to opt into the new default.

Confidence score: 4/5

  • This PR implements a well-structured deprecation strategy with minimal risk of breaking existing functionality
  • Score reflects the thorough approach to backward compatibility and clear migration path provided to users
  • Pay close attention to the frame detection logic in console.py to ensure deprecation warnings appear in the correct context

4 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 26, 2025

CodSpeed Performance Report

Merging #5739 will not alter performance

Comparing deprecate-state_auto_setters (b0ed239) with main (8d8e236)

Summary

✅ 8 untouched benchmarks

Copy link

@minthukyawdd minthukyawdd left a comment

Choose a reason for hiding this comment

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

Fix it

adhami3310 and others added 2 commits August 26, 2025 11:07
* move state_auth_setters deprecation warning to compile time

* Also warn for setvar
@adhami3310 adhami3310 merged commit 39a07b6 into main Aug 29, 2025
41 checks passed
@adhami3310 adhami3310 deleted the deprecate-state_auto_setters branch August 29, 2025 01:44
@minthukyawdd
Copy link

#5739

@minthukyawdd
Copy link

Hi there

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