fix: reject string CodeBlock theme to surface invalid values at create time#6419
fix: reject string CodeBlock theme to surface invalid values at create time#6419masenf merged 4 commits intoreflex-dev:mainfrom
Conversation
Greptile SummaryThis PR narrows the The only P2 concern is the existing docstring Confidence Score: 4/5Safe to merge; the only issue is a stale docstring that still advertises string values. The implementation is correct and well-tested. The packages/reflex-components-code/src/reflex_components_code/code.py — docstring should be updated to match the new strict type. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["CodeBlock.create(theme=value)"] --> B{Valid Var of Theme?}
B -- "Yes: Theme.one_dark etc." --> C["Validation passes"]
B -- "No: plain string passed" --> D["TypeError raised at create time"]
C --> E["Component instance created"]
D --> F["Caller sees error immediately"]
style D fill:#f66,color:#fff
style F fill:#f66,color:#fff
Reviews (1): Last reviewed commit: "fix: reject string CodeBlock theme to su..." | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
masenf
left a comment
There was a problem hiding this comment.
we should add a test to ensure that rx.color_mode_cond(light=rx.code_block.themes.one_light, dark=rx.code_block.themes.one_dark) can be passed.
check through the docs/ markdown files and doc strings for any examples that might need to be updated. also ensure the docs mention how to access the themes from the CodeBlockNamespace.
…e.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…eflex into code-block-theme # Conflicts: # packages/reflex-components-code/src/reflex_components_code/code.py
Tightens the
CodeBlock.themeprop type fromVar[Theme | str]toVar[Theme]. Passing a raw string (e.g.theme="one_dark") silently produced a broken component because the value was never resolved to an actual theme import — now it raises aTypeErrorat create time, surfacing the mistake immediately.All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features: