From c8ea434cc1c69ca9c749507ce74be92dfdb1fd66 Mon Sep 17 00:00:00 2001 From: Elijah Date: Fri, 18 Oct 2024 13:07:47 +0000 Subject: [PATCH] pyright fix --- reflex/components/core/banner.py | 4 ++-- reflex/components/datadisplay/code.py | 6 +++--- reflex/components/radix/primitives/accordion.py | 4 ++-- reflex/components/radix/themes/color_mode.py | 4 ++-- reflex/components/radix/themes/components/slider.py | 2 +- reflex/components/radix/themes/layout/list.py | 12 +++++++----- reflex/components/radix/themes/layout/stack.py | 4 ++-- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py index 902d54128..f78df8f36 100644 --- a/reflex/components/core/banner.py +++ b/reflex/components/core/banner.py @@ -166,7 +166,7 @@ class ConnectionBanner(Component): """A connection banner component.""" # The component to render when there's a server connection error. - comp: Var[Optional[Component]] = None + comp: Var[Optional[Component]] = Var.create(None) @classmethod def create(cls, **props) -> Component: @@ -198,7 +198,7 @@ class ConnectionModal(Component): """A connection status modal window.""" # The component to render when there's a server connection error. - comp: Var[Optional[Component]] = None + comp: Var[Optional[Component]] = Var.create(None) @classmethod def create(cls, **props) -> Component: diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py index 854726b26..92f4aa385 100644 --- a/reflex/components/datadisplay/code.py +++ b/reflex/components/datadisplay/code.py @@ -391,7 +391,7 @@ class CodeBlock(Component): theme: Var[Union[Theme, str]] = Theme.one_light # The language to use. - language: Var[LiteralCodeLanguage] = "python" # type: ignore + language: Var[LiteralCodeLanguage] = Var.create("python") # The code to display. code: Var[str] @@ -412,10 +412,10 @@ class CodeBlock(Component): code_tag_props: Var[Dict[str, str]] # Whether a copy button should appear. - can_copy: Var[Optional[bool]] = False + can_copy: Var[Optional[bool]] = Var.create(False) # A custom copy button to override the default one. - copy_button: Var[Optional[Union[bool, Component]]] = None + copy_button: Var[Optional[Union[bool, Component]]] = Var.create(None) def add_imports(self) -> ImportDict: """Add imports for the CodeBlock component. diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index 81121d203..60d5e0f52 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -194,10 +194,10 @@ class AccordionItem(AccordionComponent): disabled: Var[bool] # The header of the accordion item. - header: Var[Optional[Union[Component, str]]] = None + header: Var[Optional[Union[Component, str]]] = Var.create(None) # The content of the accordion item. - content: Var[Optional[Union[Component, str]]] = None + content: Var[Optional[Union[Component, str]]] = Var.create(None) _valid_children: List[str] = [ "AccordionHeader", diff --git a/reflex/components/radix/themes/color_mode.py b/reflex/components/radix/themes/color_mode.py index 2eddbde5a..78f369af0 100644 --- a/reflex/components/radix/themes/color_mode.py +++ b/reflex/components/radix/themes/color_mode.py @@ -97,10 +97,10 @@ class ColorModeIconButton(IconButton): """Icon Button for toggling light / dark mode via toggle_color_mode.""" # The position of the icon button. Follow document flow if None. - position: Var[Optional[LiteralPosition]] = None + position: Var[Optional[LiteralPosition]] = Var.create(None) # Allow picking the "system" value for the color mode. - allow_system: Var[bool] = False + allow_system: Var[bool] = Var.create(False) @classmethod def create( diff --git a/reflex/components/radix/themes/components/slider.py b/reflex/components/radix/themes/components/slider.py index 31a82d618..956bc382c 100644 --- a/reflex/components/radix/themes/components/slider.py +++ b/reflex/components/radix/themes/components/slider.py @@ -62,7 +62,7 @@ class Slider(RadixThemesComponent): name: Var[str] # The width of the slider. - width: Var[Optional[str]] = "100%" + width: Var[Optional[str]] = Var.create("100%") # The minimum value of the slider. min: Var[Union[float, int]] diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py index 04bd716b9..5328f628a 100644 --- a/reflex/components/radix/themes/layout/list.py +++ b/reflex/components/radix/themes/layout/list.py @@ -99,26 +99,28 @@ class UnorderedList(BaseList, Ul): tag = "ul" + # The style of the list. + list_style_type: Var[LiteralListStyleTypeOrdered] = Var.create("disc") + @classmethod def create( cls, *children, - items: Optional[Var[Iterable]] = None, - list_style_type: LiteralListStyleTypeUnordered = "disc", **props, ): """Create an unordered list component. Args: *children: The children of the component. - items: A list of items to add to the list. - list_style_type: The style of the list. **props: The properties of the component. Returns: The list component. """ + items = props.pop("items", None) + list_style_type = props.pop("list_style_type", "disc") + props["margin_left"] = props.get("margin_left", "1.5rem") return super().create( *children, items=items, list_style_type=list_style_type, **props @@ -131,7 +133,7 @@ class OrderedList(BaseList, Ol): tag = "ol" # The style of the list. - list_style_type: Var[LiteralListStyleTypeOrdered] = "decimal" + list_style_type: Var[LiteralListStyleTypeOrdered] = Var.create("decimal") @classmethod def create( diff --git a/reflex/components/radix/themes/layout/stack.py b/reflex/components/radix/themes/layout/stack.py index 73e079822..d11c3488b 100644 --- a/reflex/components/radix/themes/layout/stack.py +++ b/reflex/components/radix/themes/layout/stack.py @@ -13,10 +13,10 @@ class Stack(Flex): """A stack component.""" # The spacing between each stack item. - spacing: LiteralSpacing = "3" + spacing: Var[LiteralSpacing] = Var.create("3") # The alignment of the stack items. - align: LiteralAlign = "start" + align: Var[LiteralAlign] = Var.create("start") @classmethod def create(