Skip to content
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

add module prefix to generated state names #3214

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

benedikt-bartscher
Copy link
Contributor

@benedikt-bartscher benedikt-bartscher commented May 2, 2024

This PR prefixes all state names with their python module to prevent naming conflicts. Defining the same State class name multiple times in different modules is now possible. Consider this example:

myapp/pages/index.py

class State(rx.State):
  pass

myapp/pages/about.py

class State(rx.State):
  pass

Adjusted all tests except the actual State.get_name and State.get_full_name tests to use dynamic state names. This allows us to implement minified state names later.

Added get_state_name and get_full_state_name helpers to AppHarness for easy testing with parametrized app_names.

Validate state cls module names in init_subclass hook. They should not contain ___ as it's used as state name module separator.

@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review May 3, 2024 21:57
benedikt-bartscher added a commit to benedikt-bartscher/reflex that referenced this pull request May 6, 2024
picklelo pushed a commit that referenced this pull request May 7, 2024
@benedikt-bartscher benedikt-bartscher force-pushed the state-module-prefix branch 3 times, most recently from 5545a37 to 5a8d8c7 Compare May 13, 2024 00:09
@benedikt-bartscher benedikt-bartscher force-pushed the state-module-prefix branch 2 times, most recently from 189402d to fb16840 Compare May 16, 2024 16:42
@benedikt-bartscher benedikt-bartscher changed the title add module prefix to state names add module prefix to generated state names May 21, 2024
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.

None yet

1 participant