pyright fix

This commit is contained in:
Elijah 2024-10-18 13:07:47 +00:00
parent 5862672794
commit c8ea434cc1
7 changed files with 19 additions and 17 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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",

View File

@ -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(

View File

@ -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]]

View File

@ -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(

View File

@ -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(