remove a bit more unions

This commit is contained in:
Khaleel Al-Adhami 2025-02-18 16:09:22 -08:00
parent 6df5cfe43b
commit 411f46c73e
31 changed files with 116 additions and 164 deletions

View File

@ -27,7 +27,6 @@ from typing import (
Dict, Dict,
MutableMapping, MutableMapping,
Type, Type,
Union,
get_args, get_args,
get_type_hints, get_type_hints,
) )
@ -289,7 +288,7 @@ class UnevaluatedPage:
title: Var | str | None title: Var | str | None
description: Var | str | None description: Var | str | None
image: str image: str
on_load: Union[EventType[()], None] on_load: EventType[()] | None
meta: list[dict[str, str]] meta: list[dict[str, str]]
@ -399,7 +398,7 @@ class App(MiddlewareMixin, LifespanMixin):
# Backend Error Handler Function # Backend Error Handler Function
backend_exception_handler: Callable[ backend_exception_handler: Callable[
[Exception], Union[EventSpec, list[EventSpec], None] [Exception], EventSpec | list[EventSpec] | None
] = default_backend_exception_handler ] = default_backend_exception_handler
# Put the toast provider in the app wrap. # Put the toast provider in the app wrap.
@ -1491,7 +1490,7 @@ class App(MiddlewareMixin, LifespanMixin):
if not valid: if not valid:
raise ValueError( raise ValueError(
f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong return type." f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong return type."
f"Expected `Union[EventSpec, list[EventSpec], None]` but got `{return_type}`" f"Expected `EventSpec | list[EventSpec] | None` but got `{return_type}`"
) )

View File

@ -9,7 +9,7 @@ from abc import ABC, abstractmethod
from functools import lru_cache, wraps from functools import lru_cache, wraps
from hashlib import md5 from hashlib import md5
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any, Callable, ClassVar, Iterator, List, Sequence, Type, Union from typing import Any, Callable, ClassVar, Iterator, List, Sequence, Type
from typing_extensions import Self from typing_extensions import Self
@ -159,9 +159,7 @@ def evaluate_style_namespaces(style: ComponentStyle) -> dict:
# Map from component to styling. # Map from component to styling.
ComponentStyle = dict[ ComponentStyle = dict[str | Type[BaseComponent] | Callable | ComponentNamespace, Any]
Union[str, Type[BaseComponent], Callable, ComponentNamespace], Any
]
ComponentChild = types.PrimitiveType | Var | BaseComponent ComponentChild = types.PrimitiveType | Var | BaseComponent
ComponentChildTypes = (*types.PrimitiveTypes, Var, BaseComponent) ComponentChildTypes = (*types.PrimitiveTypes, Var, BaseComponent)

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import TypeVar, Union from typing import TypeVar
breakpoints_values = ["30em", "48em", "62em", "80em", "96em"] breakpoints_values = ["30em", "48em", "62em", "80em", "96em"]
breakpoint_names = ["xs", "sm", "md", "lg", "xl"] breakpoint_names = ["xs", "sm", "md", "lg", "xl"]
@ -94,4 +94,4 @@ breakpoints = Breakpoints.create
T = TypeVar("T") T = TypeVar("T")
Responsive = Union[T, Breakpoints[str, T]] Responsive = T | Breakpoints[str, T]

View File

@ -1,12 +1,10 @@
"""A Reflex logo component.""" """A Reflex logo component."""
from typing import Union
import reflex as rx import reflex as rx
def svg_logo( def svg_logo(
color: Union[str, rx.Var[str]] = rx.color_mode_cond("#110F1F", "white"), color: str | rx.Var[str] = rx.color_mode_cond("#110F1F", "white"),
**props, **props,
): ):
"""A Reflex logo SVG. """A Reflex logo SVG.

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import re import re
from collections import defaultdict from collections import defaultdict
from typing import Any, Literal, Union from typing import Any, Literal
from reflex.base import Base from reflex.base import Base
from reflex.components.component import Component, ComponentNamespace from reflex.components.component import Component, ComponentNamespace
@ -547,15 +547,13 @@ class ShikiCodeBlock(Component, MarkdownComponentMap):
theme: Var[LiteralCodeTheme] = Var.create("one-light") theme: Var[LiteralCodeTheme] = Var.create("one-light")
# The set of themes to use for different modes. # The set of themes to use for different modes.
themes: Var[Union[list[dict[str, Any]], dict[str, str]]] themes: Var[list[dict[str, Any]] | dict[str, str]]
# The code to display. # The code to display.
code: Var[str] code: Var[str]
# The transformers to use for the syntax highlighter. # The transformers to use for the syntax highlighter.
transformers: Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]] = Var.create( transformers: Var[list[ShikiBaseTransformers | dict[str, Any]]] = Var.create([])
[]
)
# The decorations to use for the syntax highlighter. # The decorations to use for the syntax highlighter.
decorations: Var[list[ShikiDecorations]] = Var.create([]) decorations: Var[list[ShikiDecorations]] = Var.create([])

View File

@ -1,6 +1,6 @@
"""Inline classes.""" """Inline classes."""
from typing import Literal, Union from typing import Literal
from reflex.vars.base import Var from reflex.vars.base import Var
@ -46,7 +46,7 @@ class A(BaseHTML): # Inherits common attributes from BaseMeta
rel: Var[str] rel: Var[str]
# Specifies where to open the linked document # Specifies where to open the linked document
target: Var[Union[str, Literal["_self", "_blank", "_parent", "_top"]]] target: Var[str | Literal["_self", "_blank", "_parent", "_top"]]
class Abbr(BaseHTML): class Abbr(BaseHTML):

View File

@ -1,6 +1,6 @@
"""Media classes.""" """Media classes."""
from typing import Any, Literal, Union from typing import Any, Literal
from reflex import Component, ComponentNamespace from reflex import Component, ComponentNamespace
from reflex.components.el.elements.inline import ReferrerPolicy from reflex.components.el.elements.inline import ReferrerPolicy
@ -472,7 +472,7 @@ class Stop(BaseHTML):
stop_color: Var[str | Color | bool] stop_color: Var[str | Color | bool]
# Opacity of the gradient stop. # Opacity of the gradient stop.
stop_opacity: Var[Union[str, float, int, bool]] stop_opacity: Var[str | float | int | bool]
class Path(BaseHTML): class Path(BaseHTML):

View File

@ -2,7 +2,6 @@
import dataclasses import dataclasses
from datetime import date, datetime, time, timedelta from datetime import date, datetime, time, timedelta
from typing import Union
from reflex.components.component import NoSSRComponent from reflex.components.component import NoSSRComponent
from reflex.event import EventHandler, passthrough_event_spec from reflex.event import EventHandler, passthrough_event_spec
@ -79,7 +78,7 @@ class Moment(NoSSRComponent):
duration: Var[str] duration: Var[str]
# The date to display (also work if passed as children). # The date to display (also work if passed as children).
date: Var[Union[str, datetime, date, time, timedelta]] date: Var[str | datetime | date | time | timedelta]
# Shows the duration (elapsed time) between now and the provided datetime. # Shows the duration (elapsed time) between now and the provided datetime.
duration_from_now: Var[bool] duration_from_now: Var[bool]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Any, Dict, TypedDict, TypeVar, Union from typing import Any, Dict, TypedDict, TypeVar
from reflex.components.component import Component, NoSSRComponent from reflex.components.component import Component, NoSSRComponent
from reflex.components.core.cond import color_mode_cond from reflex.components.core.cond import color_mode_cond
@ -35,7 +35,7 @@ def _event_points_data_signature(e0: Var) -> tuple[Var[list[Point]]]:
T = TypeVar("T") T = TypeVar("T")
ItemOrList = Union[T, list[T]] ItemOrList = T | list[T]
class BBox(TypedDict): class BBox(TypedDict):
@ -59,33 +59,10 @@ class Point(TypedDict):
lon: float | int | None lon: float | int | None
curveNumber: int | None curveNumber: int | None
pointNumber: int | None pointNumber: int | None
pointNumbers: Union[list[int], None] pointNumbers: list[int] | None
pointIndex: int | None pointIndex: int | None
markerColor: Union[ markerColor: ItemOrList[ItemOrList[float | int | str | None]] | None
ItemOrList[ markerSize: ItemOrList[ItemOrList[float | int | None,]] | None
ItemOrList[
Union[
float,
int,
str,
None,
]
]
],
None,
]
markerSize: Union[
ItemOrList[
ItemOrList[
Union[
float,
int,
None,
]
]
],
None,
]
bbox: BBox | None bbox: BBox | None

View File

@ -3,7 +3,7 @@
# ------------------- DO NOT EDIT ---------------------- # ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`! # This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------ # ------------------------------------------------------
from typing import Any, Dict, Optional, TypedDict, TypeVar, Union, overload from typing import Any, Dict, Optional, TypedDict, TypeVar, overload
from reflex.components.component import NoSSRComponent from reflex.components.component import NoSSRComponent
from reflex.event import EventType from reflex.event import EventType
@ -21,7 +21,7 @@ except ImportError:
Figure = Any Figure = Any
Template = Any Template = Any
T = TypeVar("T") T = TypeVar("T")
ItemOrList = Union[T, list[T]] ItemOrList = T | list[T]
class BBox(TypedDict): class BBox(TypedDict):
x0: float | int | None x0: float | int | None
@ -39,10 +39,10 @@ class Point(TypedDict):
lon: float | int | None lon: float | int | None
curveNumber: int | None curveNumber: int | None
pointNumber: int | None pointNumber: int | None
pointNumbers: Union[list[int], None] pointNumbers: list[int] | None
pointIndex: int | None pointIndex: int | None
markerColor: Union[ItemOrList[ItemOrList[Union[float, int, str, None]]], None] markerColor: ItemOrList[ItemOrList[float | int | str | None]] | None
markerSize: Union[ItemOrList[ItemOrList[Union[float, int, None]]], None] markerSize: ItemOrList[ItemOrList[float | int | None,]] | None
bbox: BBox | None bbox: BBox | None
class Plotly(NoSSRComponent): class Plotly(NoSSRComponent):

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Any, Literal, Union from typing import Any, Literal
from reflex.components.component import Component, ComponentNamespace from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.colors import color from reflex.components.core.colors import color
@ -95,10 +95,10 @@ class AccordionRoot(AccordionComponent):
type: Var[LiteralAccordionType] type: Var[LiteralAccordionType]
# The value of the item to expand. # The value of the item to expand.
value: Var[Union[str, list[str]]] value: Var[str | list[str]]
# The default value of the item to expand. # The default value of the item to expand.
default_value: Var[Union[str, list[str]]] default_value: Var[str | list[str]]
# Whether or not the accordion is collapsible. # Whether or not the accordion is collapsible.
collapsible: Var[bool] collapsible: Var[bool]

View File

@ -17,7 +17,7 @@ rx.text(
from __future__ import annotations from __future__ import annotations
from typing import Any, Literal, Union, get_args from typing import Any, Literal, get_args
from reflex.components.component import BaseComponent from reflex.components.component import BaseComponent
from reflex.components.core.cond import Cond, color_mode_cond, cond from reflex.components.core.cond import Cond, color_mode_cond, cond
@ -99,7 +99,7 @@ class ColorModeIconButton(IconButton):
"""Icon Button for toggling light / dark mode via toggle_color_mode.""" """Icon Button for toggling light / dark mode via toggle_color_mode."""
# The position of the icon button. Follow document flow if None. # The position of the icon button. Follow document flow if None.
position: Union[LiteralPosition, Var[LiteralPosition]] | None = None position: LiteralPosition | Var[LiteralPosition] | None = None
# Allow picking the "system" value for the color mode. # Allow picking the "system" value for the color mode.
allow_system: bool = False allow_system: bool = False

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
import reflex as rx import reflex as rx
from reflex.components.component import Component, ComponentNamespace from reflex.components.component import Component, ComponentNamespace
@ -57,7 +57,7 @@ class Callout(CalloutRoot):
icon: Var[str] icon: Var[str]
@classmethod @classmethod
def create(cls, text: Union[str, Var[str]], **props) -> Component: def create(cls, text: str | Var[str], **props) -> Component:
"""Create a callout component. """Create a callout component.
Args: Args:

View File

@ -1,7 +1,7 @@
"""Components for the Radix CheckboxCards component.""" """Components for the Radix CheckboxCards component."""
from types import SimpleNamespace from types import SimpleNamespace
from typing import Literal, Union from typing import Literal
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
from reflex.vars.base import Var from reflex.vars.base import Var
@ -27,14 +27,10 @@ class CheckboxCardsRoot(RadixThemesComponent):
high_contrast: Var[bool] high_contrast: Var[bool]
# The number of columns: # The number of columns:
columns: Var[ columns: Var[Responsive[str | Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
]
# The gap between the checkbox cards: # The gap between the checkbox cards:
gap: Var[ gap: Var[Responsive[str | Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
]
class CheckboxCardsItem(RadixThemesComponent): class CheckboxCardsItem(RadixThemesComponent):

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
from reflex.components.component import ComponentNamespace from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
@ -101,7 +101,7 @@ class ContextMenuContent(RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType] sticky: Var[LiteralStickyType]
@ -183,7 +183,7 @@ class ContextMenuSubContent(RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType] sticky: Var[LiteralStickyType]

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
from reflex.components.component import ComponentNamespace from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
@ -106,7 +106,7 @@ class DropdownMenuContent(RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType] sticky: Var[LiteralStickyType]
@ -188,7 +188,7 @@ class DropdownMenuSubContent(RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType] sticky: Var[LiteralStickyType]

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
from reflex.components.component import ComponentNamespace from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
@ -62,7 +62,7 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless
sticky: Var[Literal["partial", "always"]] sticky: Var[Literal["partial", "always"]]

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
from reflex.components.component import ComponentNamespace from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
@ -62,7 +62,7 @@ class PopoverContent(elements.Div, RadixThemesComponent):
avoid_collisions: Var[bool] avoid_collisions: Var[bool]
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, dict[str, float | int]]] collision_padding: Var[float | int | dict[str, float | int]]
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial". # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[Literal["partial", "always"]] sticky: Var[Literal["partial", "always"]]

View File

@ -1,7 +1,7 @@
"""Radio component from Radix Themes.""" """Radio component from Radix Themes."""
from types import SimpleNamespace from types import SimpleNamespace
from typing import Literal, Union from typing import Literal
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
from reflex.event import EventHandler, passthrough_event_spec from reflex.event import EventHandler, passthrough_event_spec
@ -31,14 +31,10 @@ class RadioCardsRoot(RadixThemesComponent):
high_contrast: Var[bool] high_contrast: Var[bool]
# The number of columns: # The number of columns:
columns: Var[ columns: Var[Responsive[str | Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
]
# The gap between the checkbox cards: # The gap between the checkbox cards:
gap: Var[ gap: Var[Responsive[str | Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
Responsive[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]
]
default_value: Var[str] default_value: Var[str]

View File

@ -3,7 +3,7 @@
from __future__ import annotations from __future__ import annotations
from types import SimpleNamespace from types import SimpleNamespace
from typing import Literal, Union from typing import Literal
from reflex.components.core.breakpoints import Responsive from reflex.components.core.breakpoints import Responsive
from reflex.event import EventHandler from reflex.event import EventHandler
@ -13,8 +13,8 @@ from ..base import LiteralAccentColor, RadixThemesComponent
def on_value_change( def on_value_change(
value: Var[Union[str, list[str]]], value: Var[str | list[str]],
) -> tuple[Var[Union[str, list[str]]]]: ) -> tuple[Var[str | list[str]]]:
"""Handle the on_value_change event. """Handle the on_value_change event.
Args: Args:
@ -47,10 +47,10 @@ class SegmentedControlRoot(RadixThemesComponent):
radius: Var[Literal["none", "small", "medium", "large", "full"]] radius: Var[Literal["none", "small", "medium", "large", "full"]]
# The default value of the segmented control. # The default value of the segmented control.
default_value: Var[Union[str, list[str]]] default_value: Var[str | list[str]]
# The current value of the segmented control. # The current value of the segmented control.
value: Var[Union[str, list[str]]] value: Var[str | list[str]]
# Handles the `onChange` event for the SegmentedControl component. # Handles the `onChange` event for the SegmentedControl component.
on_change: EventHandler[on_value_change] on_change: EventHandler[on_value_change]

View File

@ -4,7 +4,7 @@
# This file was generated by `reflex/utils/pyi_generator.py`! # This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------ # ------------------------------------------------------
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any, Literal, Optional, Union, overload from typing import Any, Literal, Optional, overload
from reflex.components.core.breakpoints import Breakpoints from reflex.components.core.breakpoints import Breakpoints
from reflex.event import EventType from reflex.event import EventType
@ -13,9 +13,7 @@ from reflex.vars.base import Var
from ..base import RadixThemesComponent from ..base import RadixThemesComponent
def on_value_change( def on_value_change(value: Var[str | list[str]]) -> tuple[Var[str | list[str]]]: ...
value: Var[Union[str, list[str]]],
) -> tuple[Var[Union[str, list[str]]]]: ...
class SegmentedControlRoot(RadixThemesComponent): class SegmentedControlRoot(RadixThemesComponent):
@overload @overload
@ -104,7 +102,7 @@ class SegmentedControlRoot(RadixThemesComponent):
autofocus: bool | None = None, autofocus: bool | None = None,
custom_attrs: dict[str, Var | Any] | None = None, custom_attrs: dict[str, Var | Any] | None = None,
on_blur: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None,
on_change: Optional[EventType[()] | EventType[Union[str, list[str]]]] = None, on_change: Optional[EventType[()] | EventType[str | list[str]]] = None,
on_click: Optional[EventType[()]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[()]] = None, on_context_menu: Optional[EventType[()]] = None,
on_double_click: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None,

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes.""" """Interactive components provided by @radix-ui/themes."""
from typing import Literal, Union from typing import Literal
import reflex as rx import reflex as rx
from reflex.components.component import Component, ComponentNamespace from reflex.components.component import Component, ComponentNamespace
@ -179,7 +179,7 @@ class HighLevelSelect(SelectRoot):
position: Var[Literal["item-aligned", "popper"]] position: Var[Literal["item-aligned", "popper"]]
@classmethod @classmethod
def create(cls, items: Union[list[str], Var[list[str]]], **props) -> Component: def create(cls, items: list[str] | Var[list[str]], **props) -> Component:
"""Create a select component. """Create a select component.
Args: Args:

View File

@ -413,7 +413,7 @@ class Bar(Cartesian):
max_bar_size: Var[int] max_bar_size: Var[int]
# If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0 # If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0
radius: Var[Union[int, list[int]]] radius: Var[int | list[int]]
# The active bar is shown when a user enters a bar chart and this chart has tooltip. If set to false, no active bar will be drawn. If set to true, active bar will be drawn with the props calculated internally. If passed an object, active bar will be drawn, and the internally calculated props will be merged with the key value pairs of the passed object. # The active bar is shown when a user enters a bar chart and this chart has tooltip. If set to false, no active bar will be drawn. If set to true, active bar will be drawn with the props calculated internally. If passed an object, active bar will be drawn, and the internally calculated props will be merged with the key value pairs of the passed object.
# active_bar: Var[Union[bool, dict[str, Any]]] #noqa: ERA001 # active_bar: Var[Union[bool, dict[str, Any]]] #noqa: ERA001

View File

@ -65,7 +65,7 @@ class EditorOptions(Base):
rtl: bool | None = None rtl: bool | None = None
# List of buttons to use in the toolbar. # List of buttons to use in the toolbar.
button_list: list[Union[list[str], str]] | None button_list: list[list[str] | str] | None
def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]: def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]:

View File

@ -4,7 +4,7 @@
# This file was generated by `reflex/utils/pyi_generator.py`! # This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------ # ------------------------------------------------------
import enum import enum
from typing import Any, Dict, Literal, Optional, Union, overload from typing import Any, Dict, Literal, Optional, overload
from reflex.base import Base from reflex.base import Base
from reflex.components.component import NoSSRComponent from reflex.components.component import NoSSRComponent
@ -42,7 +42,7 @@ class EditorOptions(Base):
default_tag: str | None default_tag: str | None
mode: str | None mode: str | None
rtl: bool | None rtl: bool | None
button_list: list[Union[list[str], str]] | None button_list: list[list[str] | str] | None
def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]: ... def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]: ...
def on_paste_spec( def on_paste_spec(

View File

@ -20,7 +20,6 @@ from typing import (
Type, Type,
TypedDict, TypedDict,
TypeVar, TypeVar,
Union,
get_args, get_args,
get_origin, get_origin,
get_type_hints, get_type_hints,
@ -393,9 +392,7 @@ class EventChain(EventActionsMixin):
default_factory=list default_factory=list
) )
args_spec: Union[Callable, Sequence[Callable]] | None = dataclasses.field( args_spec: Callable | Sequence[Callable] | None = dataclasses.field(default=None)
default=None
)
invocation: Var | None = dataclasses.field(default=None) invocation: Var | None = dataclasses.field(default=None)
@ -979,7 +976,7 @@ def remove_session_storage(key: str) -> EventSpec:
) )
def set_clipboard(content: Union[str, Var[str]]) -> EventSpec: def set_clipboard(content: str | Var[str]) -> EventSpec:
"""Set the text in content in the clipboard. """Set the text in content in the clipboard.
Args: Args:
@ -1943,10 +1940,10 @@ class EventNamespace(types.SimpleNamespace):
func: Callable[[BASE_STATE, Unpack[P]], Any] | None = None, func: Callable[[BASE_STATE, Unpack[P]], Any] | None = None,
*, *,
background: bool | None = None, background: bool | None = None,
) -> Union[ ) -> (
EventCallback[Unpack[P]], EventCallback[Unpack[P]]
Callable[[Callable[[BASE_STATE, Unpack[P]], Any]], EventCallback[Unpack[P]]], | Callable[[Callable[[BASE_STATE, Unpack[P]], Any]], EventCallback[Unpack[P]]]
]: ):
"""Wrap a function to be used as an event. """Wrap a function to be used as an event.
Args: Args:

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import re import re
from collections import defaultdict from collections import defaultdict
from contextlib import suppress from contextlib import suppress
from typing import Any, ClassVar, Type, Union from typing import Any, ClassVar, Type
import alembic.autogenerate import alembic.autogenerate
import alembic.command import alembic.command
@ -161,9 +161,7 @@ async def get_db_status() -> dict[str, bool]:
return {"db": status} return {"db": status}
SQLModelOrSqlAlchemy = Union[ SQLModelOrSqlAlchemy = Type[sqlmodel.SQLModel] | Type[sqlalchemy.orm.DeclarativeBase]
Type[sqlmodel.SQLModel], Type[sqlalchemy.orm.DeclarativeBase]
]
class ModelRegistry: class ModelRegistry:

View File

@ -33,7 +33,6 @@ from typing import (
Tuple, Tuple,
Type, Type,
TypeVar, TypeVar,
Union,
cast, cast,
get_args, get_args,
get_type_hints, get_type_hints,
@ -1694,7 +1693,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
return StateUpdate() return StateUpdate()
event_specs_correct_type = cast( event_specs_correct_type = cast(
Union[list[EventSpec | EventHandler], None], list[EventSpec | EventHandler] | None,
[event_specs] if isinstance(event_specs, EventSpec) else event_specs, [event_specs] if isinstance(event_specs, EventSpec) else event_specs,
) )
fixed_events = fix_events( fixed_events = fix_events(

View File

@ -2405,7 +2405,7 @@ class ComputedVar(Var[RETURN_TYPE]):
return self._fget return self._fget
class DynamicRouteVar(ComputedVar[Union[str, list[str]]]): class DynamicRouteVar(ComputedVar[str | list[str]]):
"""A ComputedVar that represents a dynamic route.""" """A ComputedVar that represents a dynamic route."""
pass pass

View File

@ -14,7 +14,6 @@ from typing import (
Sequence, Sequence,
Type, Type,
TypeVar, TypeVar,
Union,
overload, overload,
) )
@ -54,52 +53,52 @@ class FunctionVar(Var[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any]):
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, V2, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, V2, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
arg5: Union[V5, Var[V5]], arg5: V5 | Var[V5],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
def partial( def partial(
self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, V6, P], R]], self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, V6, P], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
arg5: Union[V5, Var[V5]], arg5: V5 | Var[V5],
arg6: Union[V6, Var[V6]], arg6: V6 | Var[V6],
) -> FunctionVar[ReflexCallable[P, R]]: ... ) -> FunctionVar[ReflexCallable[P, R]]: ...
@overload @overload
@ -128,52 +127,52 @@ class FunctionVar(Var[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any]):
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1], R]], arg1: Union[V1, Var[V1]] self: FunctionVar[ReflexCallable[[V1], R]], arg1: V1 | Var[V1]
) -> VarOperationCall[[V1], R]: ... ) -> VarOperationCall[[V1], R]: ...
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1, V2], R]], self: FunctionVar[ReflexCallable[[V1, V2], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
) -> VarOperationCall[[V1, V2], R]: ... ) -> VarOperationCall[[V1, V2], R]: ...
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1, V2, V3], R]], self: FunctionVar[ReflexCallable[[V1, V2, V3], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
) -> VarOperationCall[[V1, V2, V3], R]: ... ) -> VarOperationCall[[V1, V2, V3], R]: ...
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1, V2, V3, V4], R]], self: FunctionVar[ReflexCallable[[V1, V2, V3, V4], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
) -> VarOperationCall[[V1, V2, V3, V4], R]: ... ) -> VarOperationCall[[V1, V2, V3, V4], R]: ...
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5], R]], self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
arg5: Union[V5, Var[V5]], arg5: V5 | Var[V5],
) -> VarOperationCall[[V1, V2, V3, V4, V5], R]: ... ) -> VarOperationCall[[V1, V2, V3, V4, V5], R]: ...
@overload @overload
def call( def call(
self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5, V6], R]], self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5, V6], R]],
arg1: Union[V1, Var[V1]], arg1: V1 | Var[V1],
arg2: Union[V2, Var[V2]], arg2: V2 | Var[V2],
arg3: Union[V3, Var[V3]], arg3: V3 | Var[V3],
arg4: Union[V4, Var[V4]], arg4: V4 | Var[V4],
arg5: Union[V5, Var[V5]], arg5: V5 | Var[V5],
arg6: Union[V6, Var[V6]], arg6: V6 | Var[V6],
) -> VarOperationCall[[V1, V2, V3, V4, V5, V6], R]: ... ) -> VarOperationCall[[V1, V2, V3, V4, V5, V6], R]: ...
@overload @overload

View File

@ -255,7 +255,7 @@ def test_is_backend_base_variable(
(list[int], list[int], True), (list[int], list[int], True),
(list[int], list[float], True), (list[int], list[float], True),
(int | float, int | float, False), (int | float, int | float, False),
(Union[int, Var[int]], Var[int], False), (int | Var[int], Var[int], False),
(int, Any, True), (int, Any, True),
(Any, Any, True), (Any, Any, True),
(int | float, Any, True), (int | float, Any, True),