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#6419FarhanAliRaza wants to merge 1 commit 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 |
| theme: Var[Theme] = field( | ||
| default=Theme.one_light, doc='The theme to use ("light" or "dark").' | ||
| ) |
There was a problem hiding this comment.
Misleading docstring conflicts with new type restriction
The doc string 'The theme to use ("light" or "dark").' implies that plain string values like "light" or "dark" are acceptable, which directly contradicts the narrowed type Var[Theme] that now rejects strings at create time. A user following the docstring will hit a TypeError. Consider updating it to reflect the correct usage, e.g. 'The theme to use (e.g. Theme.one_light or Theme.one_dark).'
| theme: Var[Theme] = field( | |
| default=Theme.one_light, doc='The theme to use ("light" or "dark").' | |
| ) | |
| theme: Var[Theme] = field( | |
| default=Theme.one_light, doc="The theme to use (e.g. Theme.one_light or Theme.one_dark)." | |
| ) |
There was a problem hiding this comment.
valid concern by greptile here
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: