Merged
Conversation
c93db07 to
60cc30f
Compare
023d40a to
02ba981
Compare
masenf
requested changes
Nov 28, 2023
f7e57b9 to
ca82705
Compare
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Masen Furer <m_github@0x26.net>
Only track direct subclasses of each BaseState class
masenf
previously approved these changes
Nov 28, 2023
| if len(state_subclasses) > 1: | ||
| raise ValueError( | ||
| "rx.State has been subclassed multiple times. Only one subclass is allowed" | ||
| "rx.BaseState cannot be subclassed multiple times. use rx.State instead" |
Collaborator
There was a problem hiding this comment.
Suggested change
| "rx.BaseState cannot be subclassed multiple times. use rx.State instead" | |
| "rx.BaseState cannot be subclassed multiple times. Use rx.State instead." |
Comment on lines
+165
to
+167
| # reset rx.State subclasses | ||
| State.class_subclasses.clear() | ||
| # self.app_module.app. |
Collaborator
There was a problem hiding this comment.
Suggested change
| # reset rx.State subclasses | |
| State.class_subclasses.clear() | |
| # self.app_module.app. | |
| # Reset rx.State subclasses. | |
| State.class_subclasses.clear() |
| sys.path.insert(0, os.getcwd()) | ||
| app = __import__(module, fromlist=(constants.CompileVars.APP,)) | ||
| if reload: | ||
|
|
When running AppHarness or unit tests via pytest, delete duplicate state names (and basically redefine the state tree with the new class). In a previous patch i removed this bit of code (https://github.com/reflex-dev/reflex/pull/2227/files#diff-704efe440192781e072231490ac1d12defd1aba5f6debafbc7907eebcc2abcc7L304-L314). But it turns out to be necessary. So I restructured the duplicate name check a bit to indicate that this subclass resetting should only occur in testing modes, and expand a bit on why we're doing it that way.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR renames
rx.Statetorx.BaseStateand creates a base state(rx.State) for all client apps. With this approach every substate will be a child(or substate) ofrx.State. Also allows multiple inheritance fromrx.State:docs: reflex-dev/reflex-web#306