From 35a88466efbec13908a016e1bf87f4eae69a2e17 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Tue, 18 Feb 2025 14:03:59 -0800 Subject: [PATCH] use lowercase datatypes typing --- reflex/app.py | 21 ++-- reflex/app_mixins/middleware.py | 3 +- reflex/base.py | 4 +- reflex/components/component.py | 24 ++--- reflex/components/core/clipboard.py | 6 +- reflex/components/core/clipboard.pyi | 4 +- reflex/components/core/match.py | 8 +- reflex/components/core/upload.py | 2 +- reflex/components/datadisplay/dataeditor.py | 10 +- reflex/components/datadisplay/dataeditor.pyi | 8 +- reflex/components/el/elements/metadata.py | 4 +- reflex/components/gridjs/datatable.py | 6 +- reflex/components/moment/moment.py | 4 +- reflex/components/plotly/plotly.py | 10 +- reflex/components/plotly/plotly.pyi | 96 +++++++++---------- .../components/radix/primitives/accordion.py | 14 +-- .../components/radix/primitives/accordion.pyi | 10 +- reflex/components/radix/primitives/base.py | 4 +- reflex/components/radix/primitives/drawer.py | 6 +- reflex/components/radix/primitives/drawer.pyi | 6 +- reflex/components/radix/primitives/slider.py | 10 +- reflex/components/radix/primitives/slider.pyi | 12 +-- reflex/components/radix/themes/color_mode.py | 8 +- reflex/components/radix/themes/color_mode.pyi | 6 +- .../radix/themes/components/checkbox_group.py | 4 +- .../themes/components/checkbox_group.pyi | 4 +- .../radix/themes/components/context_menu.py | 14 +-- .../radix/themes/components/dropdown_menu.py | 14 +-- .../radix/themes/components/radio_group.py | 6 +- .../radix/themes/components/radio_group.pyi | 6 +- .../themes/components/segmented_control.py | 12 +-- .../themes/components/segmented_control.pyi | 12 +-- .../radix/themes/components/select.py | 14 +-- .../radix/themes/components/select.pyi | 6 +- .../radix/themes/components/slider.py | 6 +- .../radix/themes/components/slider.pyi | 8 +- .../radix/themes/components/table.py | 18 ++-- .../radix/themes/components/tabs.py | 4 +- reflex/components/recharts/cartesian.py | 42 ++++---- reflex/components/recharts/cartesian.pyi | 30 +++--- reflex/components/recharts/charts.py | 28 +++--- reflex/components/recharts/charts.pyi | 18 ++-- reflex/components/recharts/general.py | 6 +- reflex/components/recharts/general.pyi | 4 +- reflex/components/recharts/polar.py | 30 +++--- reflex/components/recharts/polar.pyi | 16 ++-- reflex/components/suneditor/editor.py | 6 +- reflex/components/suneditor/editor.pyi | 4 +- reflex/components/tags/match_tag.py | 4 +- reflex/components/tags/tag.py | 4 +- reflex/config.py | 9 +- reflex/event.py | 4 +- reflex/experimental/layout.py | 4 +- reflex/experimental/layout.pyi | 6 +- reflex/reflex.py | 6 +- reflex/state.py | 9 +- reflex/testing.py | 5 +- reflex/utils/format.py | 4 +- reflex/utils/imports.py | 8 +- reflex/utils/prerequisites.py | 6 +- reflex/utils/processes.py | 4 +- reflex/utils/pyi_generator.py | 2 +- reflex/utils/serializers.py | 3 +- reflex/utils/types.py | 8 +- reflex/vars/base.py | 28 +++--- reflex/vars/object.py | 13 ++- reflex/vars/sequence.py | 27 +++--- tests/integration/test_dynamic_routes.py | 4 +- tests/integration/test_event_actions.py | 4 +- tests/integration/test_event_chain.py | 3 +- tests/integration/test_form_submit.py | 8 +- tests/integration/test_upload.py | 12 +-- tests/units/compiler/test_compiler.py | 3 +- tests/units/components/core/test_foreach.py | 26 ++--- tests/units/components/core/test_match.py | 4 +- tests/units/components/test_component.py | 26 ++--- tests/units/states/mutation.py | 8 +- tests/units/states/upload.py | 24 ++--- tests/units/test_app.py | 18 ++-- tests/units/test_attribute_access_type.py | 54 +++++------ tests/units/test_event.py | 4 +- tests/units/test_state.py | 29 +++--- tests/units/test_var.py | 48 +++++----- tests/units/utils/test_format.py | 4 +- tests/units/utils/test_types.py | 8 +- tests/units/utils/test_utils.py | 24 ++--- tests/units/vars/test_base.py | 6 +- 87 files changed, 526 insertions(+), 543 deletions(-) diff --git a/reflex/app.py b/reflex/app.py index d0ee06ae9..0b9b62f0f 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -25,7 +25,6 @@ from typing import ( Callable, Coroutine, Dict, - List, MutableMapping, Optional, Set, @@ -293,7 +292,7 @@ class UnevaluatedPage: description: Union[Var, str, None] image: str on_load: Union[EventType[()], None] - meta: List[Dict[str, str]] + meta: list[Dict[str, str]] @dataclasses.dataclass() @@ -327,7 +326,7 @@ class App(MiddlewareMixin, LifespanMixin): style: ComponentStyle = dataclasses.field(default_factory=dict) # A list of URLs to [stylesheets](https://reflex.dev/docs/styling/custom-stylesheets/) to include in the app. - stylesheets: List[str] = dataclasses.field(default_factory=list) + stylesheets: list[str] = dataclasses.field(default_factory=list) # A component that is present on every page (defaults to the Connection Error banner). overlay_component: Optional[Union[Component, ComponentCallable]] = ( @@ -353,7 +352,7 @@ class App(MiddlewareMixin, LifespanMixin): ) # Components to add to the head of every page. - head_components: List[Component] = dataclasses.field(default_factory=list) + head_components: list[Component] = dataclasses.field(default_factory=list) # The Socket.IO AsyncServer instance. sio: Optional[AsyncServer] = None @@ -382,7 +381,7 @@ class App(MiddlewareMixin, LifespanMixin): _state_manager: Optional[StateManager] = None # Mapping from a route to event handlers to trigger when the page loads. - _load_events: Dict[str, List[IndividualEventType[()]]] = dataclasses.field( + _load_events: Dict[str, list[IndividualEventType[()]]] = dataclasses.field( default_factory=dict ) @@ -402,7 +401,7 @@ class App(MiddlewareMixin, LifespanMixin): # Backend Error Handler Function backend_exception_handler: Callable[ - [Exception], Union[EventSpec, List[EventSpec], None] + [Exception], Union[EventSpec, list[EventSpec], None] ] = default_backend_exception_handler # Put the toast provider in the app wrap. @@ -1488,7 +1487,7 @@ class App(MiddlewareMixin, LifespanMixin): valid = bool( return_type == EventSpec or return_type == Optional[EventSpec] - or return_type == List[EventSpec] + or return_type == list[EventSpec] or return_type == inspect.Signature.empty or return_type is None ) @@ -1496,7 +1495,7 @@ class App(MiddlewareMixin, LifespanMixin): if not valid: raise ValueError( 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 `Union[EventSpec, list[EventSpec], None]` but got `{return_type}`" ) @@ -1636,7 +1635,7 @@ def upload(app: App): The upload function. """ - async def upload_file(request: Request, files: List[FastAPIUploadFile]): + async def upload_file(request: Request, files: list[FastAPIUploadFile]): """Upload a file. Args: @@ -1676,7 +1675,7 @@ def upload(app: App): # get handler function func = getattr(type(current_state), handler.split(".")[-1]) - # check if there exists any handler args with annotation, List[UploadFile] + # check if there exists any handler args with annotation, list[UploadFile] if isinstance(func, EventHandler): if func.is_background: raise UploadTypeError( @@ -1696,7 +1695,7 @@ def upload(app: App): if not handler_upload_param: raise UploadValueError( f"`{handler}` handler should have a parameter annotated as " - "List[rx.UploadFile]" + "list[rx.UploadFile]" ) # Make a copy of the files as they are closed after the request. diff --git a/reflex/app_mixins/middleware.py b/reflex/app_mixins/middleware.py index c81fd7806..0ace7cd84 100644 --- a/reflex/app_mixins/middleware.py +++ b/reflex/app_mixins/middleware.py @@ -4,7 +4,6 @@ from __future__ import annotations import asyncio import dataclasses -from typing import List from reflex.event import Event from reflex.middleware import HydrateMiddleware, Middleware @@ -18,7 +17,7 @@ class MiddlewareMixin(AppMixin): """Middleware Mixin that allow to add middleware to the app.""" # Middleware to add to the app. Users should use `add_middleware`. PRIVATE. - middleware: List[Middleware] = dataclasses.field(default_factory=list) + middleware: list[Middleware] = dataclasses.field(default_factory=list) def _init_mixin(self): self.middleware.append(HydrateMiddleware()) diff --git a/reflex/base.py b/reflex/base.py index c900f0039..61905a9bd 100644 --- a/reflex/base.py +++ b/reflex/base.py @@ -3,14 +3,14 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Any, List, Type +from typing import TYPE_CHECKING, Any, Type import pydantic.v1.main as pydantic_main from pydantic.v1 import BaseModel from pydantic.v1.fields import ModelField -def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None: +def validate_field_name(bases: list[Type["BaseModel"]], field_name: str) -> None: """Ensure that the field's name does not shadow an existing attribute of the model. Args: diff --git a/reflex/components/component.py b/reflex/components/component.py index 005f7791d..40b92696e 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -72,16 +72,16 @@ class BaseComponent(Base, ABC): """ # The children nested within the component. - children: List[BaseComponent] = [] + children: list[BaseComponent] = [] # The library that the component is based on. library: Optional[str] = None # List here the non-react dependency needed by `library` - lib_dependencies: List[str] = [] + lib_dependencies: list[str] = [] # List here the dependencies that need to be transpiled by Next.js - transpile_packages: List[str] = [] + transpile_packages: list[str] = [] # The tag to use when rendering the component. tag: Optional[str] = None @@ -216,19 +216,19 @@ class Component(BaseComponent, ABC): class_name: Any = None # Special component props. - special_props: List[Var] = [] + special_props: list[Var] = [] # Whether the component should take the focus once the page is loaded autofocus: bool = False # components that cannot be children - _invalid_children: List[str] = [] + _invalid_children: list[str] = [] # only components that are allowed as children - _valid_children: List[str] = [] + _valid_children: list[str] = [] # only components that are allowed as parent - _valid_parents: List[str] = [] + _valid_parents: list[str] = [] # props to change the name of _rename_props: Dict[str, str] = {} @@ -527,7 +527,7 @@ class Component(BaseComponent, ABC): if isinstance(class_name, (List, tuple)): if any(isinstance(c, Var) for c in class_name): kwargs["class_name"] = LiteralArrayVar.create( - class_name, _var_type=List[str] + class_name, _var_type=list[str] ).join(" ") else: kwargs["class_name"] = " ".join(class_name) @@ -876,7 +876,7 @@ class Component(BaseComponent, ABC): if prop.startswith(old_prop): rendered_dict["props"][ix] = prop.replace(old_prop, new_prop, 1) - def _validate_component_children(self, children: List[Component]): + def _validate_component_children(self, children: list[Component]): """Validate the children components. Args: @@ -986,7 +986,7 @@ class Component(BaseComponent, ABC): Each var referenced by the component (props, styles, event handlers). """ ignore_ids = ignore_ids or set() - vars: List[Var] | None = getattr(self, "__vars", None) + vars: list[Var] | None = getattr(self, "__vars", None) if vars is not None: yield from vars vars = self.__vars = [] @@ -1181,7 +1181,7 @@ class Component(BaseComponent, ABC): # Return the dynamic imports return dynamic_imports - def _get_props_imports(self) -> List[ParsedImportDict]: + def _get_props_imports(self) -> list[ParsedImportDict]: """Get the imports needed for components props. Returns: @@ -1756,7 +1756,7 @@ class CustomComponent(Component): """ return super()._render(props=self.props) - def get_prop_vars(self) -> List[Var]: + def get_prop_vars(self) -> list[Var]: """Get the prop vars. Returns: diff --git a/reflex/components/core/clipboard.py b/reflex/components/core/clipboard.py index 644de80d0..a9ddd64bd 100644 --- a/reflex/components/core/clipboard.py +++ b/reflex/components/core/clipboard.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Tuple, Union +from typing import Dict, Tuple, Union from reflex.components.base.fragment import Fragment from reflex.components.tags.tag import Tag @@ -18,10 +18,10 @@ class Clipboard(Fragment): """Clipboard component.""" # The element ids to attach the event listener to. Defaults to all child components or the document. - targets: Var[List[str]] + targets: Var[list[str]] # Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri. - on_paste: EventHandler[passthrough_event_spec(List[Tuple[str, str]])] + on_paste: EventHandler[passthrough_event_spec(list[Tuple[str, str]])] # Save the original event actions for the on_paste event. on_paste_event_actions: Var[Dict[str, Union[bool, int]]] diff --git a/reflex/components/core/clipboard.pyi b/reflex/components/core/clipboard.pyi index 2e70dccec..543d39472 100644 --- a/reflex/components/core/clipboard.pyi +++ b/reflex/components/core/clipboard.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.base.fragment import Fragment from reflex.event import EventType @@ -17,7 +17,7 @@ class Clipboard(Fragment): def create( # type: ignore cls, *children, - targets: Optional[Union[List[str], Var[List[str]]]] = None, + targets: Optional[Union[Var[list[str]], list[str]]] = None, on_paste_event_actions: Optional[ Union[Dict[str, Union[bool, int]], Var[Dict[str, Union[bool, int]]]] ] = None, diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py index 2d936544a..0e697ddf9 100644 --- a/reflex/components/core/match.py +++ b/reflex/components/core/match.py @@ -21,7 +21,7 @@ class Match(MemoizationLeaf): cond: Var[Any] # The list of match cases to be matched. - match_cases: List[Any] = [] + match_cases: list[Any] = [] # The catchall case to match. default: Any @@ -125,7 +125,7 @@ class Match(MemoizationLeaf): return case_element @classmethod - def _process_match_cases(cls, cases: List) -> List[List[Var]]: + def _process_match_cases(cls, cases: List) -> list[list[Var]]: """Process the individual match cases. Args: @@ -166,7 +166,7 @@ class Match(MemoizationLeaf): return match_cases @classmethod - def _validate_return_types(cls, match_cases: List[List[Var]]) -> None: + def _validate_return_types(cls, match_cases: list[list[Var]]) -> None: """Validate that match cases have the same return types. Args: @@ -195,7 +195,7 @@ class Match(MemoizationLeaf): def _create_match_cond_var_or_component( cls, match_cond_var: Var, - match_cases: List[List[Var]], + match_cases: list[list[Var]], default: Optional[Union[Var, BaseComponent]], ) -> Union[Component, Var]: """Create and return the match condition var or component. diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index 682fd45a9..a96fc0ad2 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -86,7 +86,7 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: id_var = LiteralStringVar.create(id_) return Var( _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])", - _var_type=List[str], + _var_type=list[str], _var_data=VarData.merge( upload_files_context_var_data, id_var._get_all_var_data() ), diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index 8179e15aa..327f873c5 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -3,7 +3,7 @@ from __future__ import annotations from enum import Enum -from typing import Any, Dict, List, Literal, Optional, Tuple, TypedDict, Union +from typing import Any, Dict, Literal, Optional, Tuple, TypedDict, Union from reflex.base import Base from reflex.components.component import Component, NoSSRComponent @@ -148,7 +148,7 @@ class GroupHeaderClickedEventArgs(TypedDict): class GridCell(TypedDict): """The grid cell.""" - span: Optional[List[int]] + span: Optional[list[int]] class GridColumn(TypedDict): @@ -164,7 +164,7 @@ class DataEditor(NoSSRComponent): tag = "DataEditor" is_default = True library: str | None = "@glideapps/glide-data-grid@^6.0.3" - lib_dependencies: List[str] = [ + lib_dependencies: list[str] = [ "lodash@^4.17.21", "react-responsive-carousel@^3.2.7", ] @@ -173,10 +173,10 @@ class DataEditor(NoSSRComponent): rows: Var[int] # Headers of the columns for the data grid. - columns: Var[List[Dict[str, Any]]] + columns: Var[list[Dict[str, Any]]] # The data. - data: Var[List[List[Any]]] + data: Var[list[list[Any]]] # The name of the callback used to find the data to display. get_cell_content: Var[str] diff --git a/reflex/components/datadisplay/dataeditor.pyi b/reflex/components/datadisplay/dataeditor.pyi index 770178f55..11bb7e440 100644 --- a/reflex/components/datadisplay/dataeditor.pyi +++ b/reflex/components/datadisplay/dataeditor.pyi @@ -4,7 +4,7 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from enum import Enum -from typing import Any, Dict, List, Literal, Optional, TypedDict, Union, overload +from typing import Any, Dict, Literal, Optional, TypedDict, Union, overload from reflex.base import Base from reflex.components.component import NoSSRComponent @@ -118,7 +118,7 @@ class GroupHeaderClickedEventArgs(TypedDict): scrollEdge: tuple[int, int] class GridCell(TypedDict): - span: Optional[List[int]] + span: Optional[list[int]] class GridColumn(TypedDict): title: str @@ -134,9 +134,9 @@ class DataEditor(NoSSRComponent): *children, rows: Optional[Union[Var[int], int]] = None, columns: Optional[ - Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] + Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]] ] = None, - data: Optional[Union[List[List[Any]], Var[List[List[Any]]]]] = None, + data: Optional[Union[Var[list[list[Any]]], list[list[Any]]]] = None, get_cell_content: Optional[Union[Var[str], str]] = None, get_cells_for_selection: Optional[Union[Var[bool], bool]] = None, on_paste: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/el/elements/metadata.py b/reflex/components/el/elements/metadata.py index 7f8efb70f..98aeaeecb 100644 --- a/reflex/components/el/elements/metadata.py +++ b/reflex/components/el/elements/metadata.py @@ -1,7 +1,5 @@ """Metadata classes.""" -from typing import List - from reflex.components.el.element import Element from reflex.components.el.elements.inline import ReferrerPolicy from reflex.components.el.elements.media import CrossOrigin @@ -91,7 +89,7 @@ class StyleEl(Element): media: Var[str] - special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")] + special_props: list[Var] = [Var(_js_expr="suppressHydrationWarning")] base = Base.create diff --git a/reflex/components/gridjs/datatable.py b/reflex/components/gridjs/datatable.py index bd568d84a..b09195816 100644 --- a/reflex/components/gridjs/datatable.py +++ b/reflex/components/gridjs/datatable.py @@ -17,7 +17,7 @@ class Gridjs(Component): library = "gridjs-react@6.1.1" - lib_dependencies: List[str] = ["gridjs@6.2.0"] + lib_dependencies: list[str] = ["gridjs@6.2.0"] class DataTable(Gridjs): @@ -115,11 +115,11 @@ class DataTable(Gridjs): if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type): self.columns = self.data._replace( _js_expr=f"{self.data._js_expr}.columns", - _var_type=List[Any], + _var_type=list[Any], ) self.data = self.data._replace( _js_expr=f"{self.data._js_expr}.data", - _var_type=List[List[Any]], + _var_type=list[list[Any]], ) if types.is_dataframe(type(self.data)): # If given a pandas df break up the data and columns diff --git a/reflex/components/moment/moment.py b/reflex/components/moment/moment.py index a5fe79f07..81bd3a1cc 100644 --- a/reflex/components/moment/moment.py +++ b/reflex/components/moment/moment.py @@ -2,7 +2,7 @@ import dataclasses from datetime import date, datetime, time, timedelta -from typing import List, Optional, Union +from typing import Optional, Union from reflex.components.component import NoSSRComponent from reflex.event import EventHandler, passthrough_event_spec @@ -31,7 +31,7 @@ class Moment(NoSSRComponent): tag: str | None = "Moment" is_default = True library: str | None = "react-moment" - lib_dependencies: List[str] = ["moment"] + lib_dependencies: list[str] = ["moment"] # How often the date update (how often time update / 0 to disable). interval: Var[int] diff --git a/reflex/components/plotly/plotly.py b/reflex/components/plotly/plotly.py index 5c41cf3e4..27213196f 100644 --- a/reflex/components/plotly/plotly.py +++ b/reflex/components/plotly/plotly.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Tuple, TypedDict, TypeVar, Union +from typing import Any, Dict, Tuple, TypedDict, TypeVar, Union from reflex.components.component import Component, NoSSRComponent from reflex.components.core.cond import color_mode_cond @@ -21,7 +21,7 @@ except ImportError: Template = Any -def _event_points_data_signature(e0: Var) -> Tuple[Var[List[Point]]]: +def _event_points_data_signature(e0: Var) -> Tuple[Var[list[Point]]]: """For plotly events with event data containing a point array. Args: @@ -35,7 +35,7 @@ def _event_points_data_signature(e0: Var) -> Tuple[Var[List[Point]]]: T = TypeVar("T") -ItemOrList = Union[T, List[T]] +ItemOrList = Union[T, list[T]] class BBox(TypedDict): @@ -59,7 +59,7 @@ class Point(TypedDict): lon: Union[float, int, None] curveNumber: Union[int, None] pointNumber: Union[int, None] - pointNumbers: Union[List[int], None] + pointNumbers: Union[list[int], None] pointIndex: Union[int, None] markerColor: Union[ ItemOrList[ @@ -94,7 +94,7 @@ class Plotly(NoSSRComponent): library = "react-plotly.js@2.6.0" - lib_dependencies: List[str] = ["plotly.js@2.35.3"] + lib_dependencies: list[str] = ["plotly.js@2.35.3"] tag = "Plot" diff --git a/reflex/components/plotly/plotly.pyi b/reflex/components/plotly/plotly.pyi index 2a26b42c6..eb0bb78e4 100644 --- a/reflex/components/plotly/plotly.pyi +++ b/reflex/components/plotly/plotly.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Optional, TypedDict, TypeVar, Union, overload +from typing import Any, Dict, Optional, TypedDict, TypeVar, Union, overload from reflex.components.component import NoSSRComponent from reflex.event import EventType @@ -21,7 +21,7 @@ except ImportError: Figure = Any Template = Any T = TypeVar("T") -ItemOrList = Union[T, List[T]] +ItemOrList = Union[T, list[T]] class BBox(TypedDict): x0: Union[float, int, None] @@ -39,7 +39,7 @@ class Point(TypedDict): lon: Union[float, int, None] curveNumber: Union[int, None] pointNumber: Union[int, None] - pointNumbers: Union[List[int], None] + pointNumbers: Union[list[int], None] pointIndex: Union[int, None] markerColor: Union[ItemOrList[ItemOrList[Union[float, int, str, None]]], None] markerSize: Union[ItemOrList[ItemOrList[Union[float, int, None]]], None] @@ -72,12 +72,12 @@ class Plotly(NoSSRComponent): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -91,11 +91,11 @@ class Plotly(NoSSRComponent): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "Plotly": @@ -171,12 +171,12 @@ class PlotlyBasic(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -190,11 +190,11 @@ class PlotlyBasic(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyBasic": @@ -266,12 +266,12 @@ class PlotlyCartesian(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -285,11 +285,11 @@ class PlotlyCartesian(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyCartesian": @@ -361,12 +361,12 @@ class PlotlyGeo(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -380,11 +380,11 @@ class PlotlyGeo(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyGeo": @@ -456,12 +456,12 @@ class PlotlyGl3d(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -475,11 +475,11 @@ class PlotlyGl3d(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyGl3d": @@ -551,12 +551,12 @@ class PlotlyGl2d(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -570,11 +570,11 @@ class PlotlyGl2d(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyGl2d": @@ -646,12 +646,12 @@ class PlotlyMapbox(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -665,11 +665,11 @@ class PlotlyMapbox(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyMapbox": @@ -741,12 +741,12 @@ class PlotlyFinance(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -760,11 +760,11 @@ class PlotlyFinance(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyFinance": @@ -836,12 +836,12 @@ class PlotlyStrict(Plotly): on_before_hover: Optional[EventType[()]] = None, on_blur: Optional[EventType[()]] = None, on_button_clicked: Optional[EventType[()]] = None, - on_click: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_click: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_context_menu: Optional[EventType[()]] = None, on_deselect: Optional[EventType[()]] = None, on_double_click: Optional[EventType[()]] = None, on_focus: Optional[EventType[()]] = None, - on_hover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_hover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_mount: Optional[EventType[()]] = None, on_mouse_down: Optional[EventType[()]] = None, on_mouse_enter: Optional[EventType[()]] = None, @@ -855,11 +855,11 @@ class PlotlyStrict(Plotly): on_relayouting: Optional[EventType[()]] = None, on_restyle: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, - on_selected: Optional[Union[EventType[()], EventType[List[Point]]]] = None, - on_selecting: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_selected: Optional[Union[EventType[()], EventType[list[Point]]]] = None, + on_selecting: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_transition_interrupted: Optional[EventType[()]] = None, on_transitioning: Optional[EventType[()]] = None, - on_unhover: Optional[Union[EventType[()], EventType[List[Point]]]] = None, + on_unhover: Optional[Union[EventType[()], EventType[list[Point]]]] = None, on_unmount: Optional[EventType[()]] = None, **props, ) -> "PlotlyStrict": diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index 90a1c41f0..d8b8e52f0 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Literal, Tuple, Union +from typing import Any, Literal, Tuple, Union from reflex.components.component import Component, ComponentNamespace from reflex.components.core.colors import color @@ -72,7 +72,7 @@ class AccordionComponent(RadixPrimitiveComponent): return ["color_scheme", "variant"] -def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: +def on_value_change(value: Var[str | list[str]]) -> Tuple[Var[str | list[str]]]: """Handle the on_value_change event. Args: @@ -95,10 +95,10 @@ class AccordionRoot(AccordionComponent): type: Var[LiteralAccordionType] # The value of the item to expand. - value: Var[Union[str, List[str]]] + value: Var[Union[str, list[str]]] # The default value of the item to expand. - default_value: Var[Union[str, List[str]]] + default_value: Var[Union[str, list[str]]] # Whether or not the accordion is collapsible. collapsible: Var[bool] @@ -124,7 +124,7 @@ class AccordionRoot(AccordionComponent): # Whether to show divider lines between items. show_dividers: Var[bool] - _valid_children: List[str] = ["AccordionItem"] + _valid_children: list[str] = ["AccordionItem"] # Fired when the opened the accordions changes. on_value_change: EventHandler[on_value_change] @@ -201,13 +201,13 @@ class AccordionItem(AccordionComponent): # The content of the accordion item. content: Var[Union[Component, str, None]] = Var.create(None) - _valid_children: List[str] = [ + _valid_children: list[str] = [ "AccordionHeader", "AccordionTrigger", "AccordionContent", ] - _valid_parents: List[str] = ["AccordionRoot"] + _valid_parents: list[str] = ["AccordionRoot"] @classmethod def create( diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi index 32bde5037..9946d5202 100644 --- a/reflex/components/radix/primitives/accordion.pyi +++ b/reflex/components/radix/primitives/accordion.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload +from typing import Any, Dict, Literal, Optional, Tuple, Union, overload from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon @@ -138,7 +138,7 @@ class AccordionComponent(RadixPrimitiveComponent): """ ... -def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: ... +def on_value_change(value: Var[str | list[str]]) -> Tuple[Var[str | list[str]]]: ... class AccordionRoot(AccordionComponent): def add_style(self): ... @@ -150,9 +150,9 @@ class AccordionRoot(AccordionComponent): type: Optional[ Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, - value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, + value: Optional[Union[Var[Union[list[str], str]], list[str], str]] = None, default_value: Optional[ - Union[List[str], Var[Union[List[str], str]], str] + Union[Var[Union[list[str], str]], list[str], str] ] = None, collapsible: Optional[Union[Var[bool], bool]] = None, disabled: Optional[Union[Var[bool], bool]] = None, @@ -263,7 +263,7 @@ class AccordionRoot(AccordionComponent): on_scroll: Optional[EventType[()]] = None, on_unmount: Optional[EventType[()]] = None, on_value_change: Optional[ - Union[EventType[()], EventType[str | List[str]]] + Union[EventType[()], EventType[str | list[str]]] ] = None, **props, ) -> "AccordionRoot": diff --git a/reflex/components/radix/primitives/base.py b/reflex/components/radix/primitives/base.py index 479cd2912..815c50ac0 100644 --- a/reflex/components/radix/primitives/base.py +++ b/reflex/components/radix/primitives/base.py @@ -1,7 +1,5 @@ """The base component for Radix primitives.""" -from typing import List - from reflex.components.component import Component from reflex.components.tags.tag import Tag from reflex.utils import format @@ -14,7 +12,7 @@ class RadixPrimitiveComponent(Component): # Change the default rendered element for the one passed as a child. as_child: Var[bool] - lib_dependencies: List[str] = ["@emotion/react@^11.11.1"] + lib_dependencies: list[str] = ["@emotion/react@^11.11.1"] class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent): diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py index 30d1a6ae3..063fa0370 100644 --- a/reflex/components/radix/primitives/drawer.py +++ b/reflex/components/radix/primitives/drawer.py @@ -4,7 +4,7 @@ # Style based on https://ui.shadcn.com/docs/components/drawer from __future__ import annotations -from typing import Any, List, Literal, Optional, Union +from typing import Any, Literal, Optional, Union from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponent @@ -20,7 +20,7 @@ class DrawerComponent(RadixPrimitiveComponent): library = "vaul" - lib_dependencies: List[str] = ["@radix-ui/react-dialog@^1.0.5"] + lib_dependencies: list[str] = ["@radix-ui/react-dialog@^1.0.5"] LiteralDirectionType = Literal["top", "bottom", "left", "right"] @@ -58,7 +58,7 @@ class DrawerRoot(DrawerComponent): handle_only: Var[bool] # Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. - snap_points: Optional[List[Union[str, float]]] + snap_points: Optional[list[Union[str, float]]] # Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. fade_from_index: Var[int] diff --git a/reflex/components/radix/primitives/drawer.pyi b/reflex/components/radix/primitives/drawer.pyi index 42c7b734b..f6f70234a 100644 --- a/reflex/components/radix/primitives/drawer.pyi +++ b/reflex/components/radix/primitives/drawer.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponent @@ -78,7 +78,7 @@ class DrawerRoot(DrawerComponent): ] = None, dismissible: Optional[Union[Var[bool], bool]] = None, handle_only: Optional[Union[Var[bool], bool]] = None, - snap_points: Optional[List[Union[float, str]]] = None, + snap_points: Optional[list[Union[float, str]]] = None, fade_from_index: Optional[Union[Var[int], int]] = None, scroll_lock_timeout: Optional[Union[Var[int], int]] = None, prevent_scroll_restoration: Optional[Union[Var[bool], bool]] = None, @@ -560,7 +560,7 @@ class Drawer(ComponentNamespace): ] = None, dismissible: Optional[Union[Var[bool], bool]] = None, handle_only: Optional[Union[Var[bool], bool]] = None, - snap_points: Optional[List[Union[float, str]]] = None, + snap_points: Optional[list[Union[float, str]]] = None, fade_from_index: Optional[Union[Var[int], int]] = None, scroll_lock_timeout: Optional[Union[Var[int], int]] = None, prevent_scroll_restoration: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/components/radix/primitives/slider.py b/reflex/components/radix/primitives/slider.py index 6136e3171..4e5898398 100644 --- a/reflex/components/radix/primitives/slider.py +++ b/reflex/components/radix/primitives/slider.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Literal, Tuple +from typing import Any, Literal, Tuple from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName @@ -20,8 +20,8 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): def on_value_event_spec( - value: Var[List[int]], -) -> Tuple[Var[List[int]]]: + value: Var[list[int]], +) -> Tuple[Var[list[int]]]: """Event handler spec for the value event. Args: @@ -39,9 +39,9 @@ class SliderRoot(SliderComponent): tag = "Root" alias = "RadixSliderRoot" - default_value: Var[List[int]] + default_value: Var[list[int]] - value: Var[List[int]] + value: Var[list[int]] name: Var[str] diff --git a/reflex/components/radix/primitives/slider.pyi b/reflex/components/radix/primitives/slider.pyi index 48099037d..3971f4c8e 100644 --- a/reflex/components/radix/primitives/slider.pyi +++ b/reflex/components/radix/primitives/slider.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload +from typing import Any, Dict, Literal, Optional, Tuple, Union, overload from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName @@ -62,7 +62,7 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): """ ... -def on_value_event_spec(value: Var[List[int]]) -> Tuple[Var[List[int]]]: ... +def on_value_event_spec(value: Var[list[int]]) -> Tuple[Var[list[int]]]: ... class SliderRoot(SliderComponent): def add_style(self) -> dict[str, Any] | None: ... @@ -71,8 +71,8 @@ class SliderRoot(SliderComponent): def create( # type: ignore cls, *children, - default_value: Optional[Union[List[int], Var[List[int]]]] = None, - value: Optional[Union[List[int], Var[List[int]]]] = None, + default_value: Optional[Union[Var[list[int]], list[int]]] = None, + value: Optional[Union[Var[list[int]], list[int]]] = None, name: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ @@ -109,8 +109,8 @@ class SliderRoot(SliderComponent): on_mouse_up: Optional[EventType[()]] = None, on_scroll: Optional[EventType[()]] = None, on_unmount: Optional[EventType[()]] = None, - on_value_change: Optional[Union[EventType[()], EventType[List[int]]]] = None, - on_value_commit: Optional[Union[EventType[()], EventType[List[int]]]] = None, + on_value_change: Optional[Union[EventType[()], EventType[list[int]]]] = None, + on_value_commit: Optional[Union[EventType[()], EventType[list[int]]]] = None, **props, ) -> "SliderRoot": """Create the component. diff --git a/reflex/components/radix/themes/color_mode.py b/reflex/components/radix/themes/color_mode.py index 0718aaac9..af62ba348 100644 --- a/reflex/components/radix/themes/color_mode.py +++ b/reflex/components/radix/themes/color_mode.py @@ -17,7 +17,7 @@ rx.text( from __future__ import annotations -from typing import Any, Dict, List, Literal, Optional, Union, get_args +from typing import Any, Dict, Literal, Optional, Union, get_args from reflex.components.component import BaseComponent from reflex.components.core.cond import Cond, color_mode_cond, cond @@ -66,9 +66,9 @@ class ColorModeIcon(Cond): LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"] -position_values: List[str] = list(get_args(LiteralPosition)) +position_values: list[str] = list(get_args(LiteralPosition)) -position_map: Dict[str, List[str]] = { +position_map: Dict[str, list[str]] = { "position": position_values, "left": ["top-left", "bottom-left"], "right": ["top-right", "bottom-right"], @@ -78,7 +78,7 @@ position_map: Dict[str, List[str]] = { # needed to inverse contains for find -def _find(const: List[str], var: Any): +def _find(const: list[str], var: Any): return LiteralArrayVar.create(const).contains(var) diff --git a/reflex/components/radix/themes/color_mode.pyi b/reflex/components/radix/themes/color_mode.pyi index deb2dd5f2..4c14b6d8a 100644 --- a/reflex/components/radix/themes/color_mode.pyi +++ b/reflex/components/radix/themes/color_mode.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import BaseComponent from reflex.components.core.breakpoints import Breakpoints @@ -63,8 +63,8 @@ class ColorModeIcon(Cond): ... LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"] -position_values: List[str] -position_map: Dict[str, List[str]] +position_values: list[str] +position_map: Dict[str, list[str]] class ColorModeIconButton(IconButton): @overload diff --git a/reflex/components/radix/themes/components/checkbox_group.py b/reflex/components/radix/themes/components/checkbox_group.py index f6379e588..967e0cb8c 100644 --- a/reflex/components/radix/themes/components/checkbox_group.py +++ b/reflex/components/radix/themes/components/checkbox_group.py @@ -1,7 +1,7 @@ """Components for the CheckboxGroup component of Radix Themes.""" from types import SimpleNamespace -from typing import List, Literal +from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.vars.base import Var @@ -27,7 +27,7 @@ class CheckboxGroupRoot(RadixThemesComponent): high_contrast: Var[bool] # determines which checkboxes, if any, are checked by default. - default_value: Var[List[str]] + default_value: Var[list[str]] # used to assign a name to the entire group of checkboxes name: Var[str] diff --git a/reflex/components/radix/themes/components/checkbox_group.pyi b/reflex/components/radix/themes/components/checkbox_group.pyi index 713710b70..b423dd94c 100644 --- a/reflex/components/radix/themes/components/checkbox_group.pyi +++ b/reflex/components/radix/themes/components/checkbox_group.pyi @@ -4,7 +4,7 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventType @@ -99,7 +99,7 @@ class CheckboxGroupRoot(RadixThemesComponent): ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - default_value: Optional[Union[List[str], Var[List[str]]]] = None, + default_value: Optional[Union[Var[list[str]], list[str]]] = None, name: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, diff --git a/reflex/components/radix/themes/components/context_menu.py b/reflex/components/radix/themes/components/context_menu.py index 60d23db1a..0b575b8b8 100644 --- a/reflex/components/radix/themes/components/context_menu.py +++ b/reflex/components/radix/themes/components/context_menu.py @@ -1,6 +1,6 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Dict, List, Literal, Union +from typing import Dict, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive @@ -35,7 +35,7 @@ class ContextMenuRoot(RadixThemesComponent): # The modality of the context menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers. modal: Var[bool] - _invalid_children: List[str] = ["ContextMenuItem"] + _invalid_children: list[str] = ["ContextMenuItem"] # Fired when the open state changes. on_open_change: EventHandler[passthrough_event_spec(bool)] @@ -52,9 +52,9 @@ class ContextMenuTrigger(RadixThemesComponent): # Whether the trigger is disabled disabled: Var[bool] - _valid_parents: List[str] = ["ContextMenuRoot"] + _valid_parents: list[str] = ["ContextMenuRoot"] - _invalid_children: List[str] = ["ContextMenuContent"] + _invalid_children: list[str] = ["ContextMenuContent"] _memoization_mode = MemoizationMode(recursive=False) @@ -154,7 +154,7 @@ class ContextMenuSubTrigger(RadixThemesComponent): # Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. text_value: Var[str] - _valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSub"] + _valid_parents: list[str] = ["ContextMenuContent", "ContextMenuSub"] _memoization_mode = MemoizationMode(recursive=False) @@ -191,7 +191,7 @@ class ContextMenuSubContent(RadixThemesComponent): # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. hide_when_detached: Var[bool] - _valid_parents: List[str] = ["ContextMenuSub"] + _valid_parents: list[str] = ["ContextMenuSub"] # Fired when the escape key is pressed. on_escape_key_down: EventHandler[no_args_event_spec] @@ -226,7 +226,7 @@ class ContextMenuItem(RadixThemesComponent): # Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside. text_value: Var[str] - _valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSubContent"] + _valid_parents: list[str] = ["ContextMenuContent", "ContextMenuSubContent"] # Fired when the item is selected. on_select: EventHandler[no_args_event_spec] diff --git a/reflex/components/radix/themes/components/dropdown_menu.py b/reflex/components/radix/themes/components/dropdown_menu.py index 6d5709e11..2645c5a56 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.py +++ b/reflex/components/radix/themes/components/dropdown_menu.py @@ -1,6 +1,6 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Dict, List, Literal, Union +from typing import Dict, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive @@ -43,7 +43,7 @@ class DropdownMenuRoot(RadixThemesComponent): # The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. dir: Var[LiteralDirType] - _invalid_children: List[str] = ["DropdownMenuItem"] + _invalid_children: list[str] = ["DropdownMenuItem"] # Fired when the open state changes. on_open_change: EventHandler[passthrough_event_spec(bool)] @@ -57,9 +57,9 @@ class DropdownMenuTrigger(RadixThemesTriggerComponent): # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. as_child: Var[bool] - _valid_parents: List[str] = ["DropdownMenuRoot"] + _valid_parents: list[str] = ["DropdownMenuRoot"] - _invalid_children: List[str] = ["DropdownMenuContent"] + _invalid_children: list[str] = ["DropdownMenuContent"] _memoization_mode = MemoizationMode(recursive=False) @@ -144,7 +144,7 @@ class DropdownMenuSubTrigger(RadixThemesTriggerComponent): # Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. text_value: Var[str] - _valid_parents: List[str] = ["DropdownMenuContent", "DropdownMenuSub"] + _valid_parents: list[str] = ["DropdownMenuContent", "DropdownMenuSub"] _memoization_mode = MemoizationMode(recursive=False) @@ -196,7 +196,7 @@ class DropdownMenuSubContent(RadixThemesComponent): # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. hide_when_detached: Var[bool] - _valid_parents: List[str] = ["DropdownMenuSub"] + _valid_parents: list[str] = ["DropdownMenuSub"] # Fired when the escape key is pressed. on_escape_key_down: EventHandler[no_args_event_spec] @@ -231,7 +231,7 @@ class DropdownMenuItem(RadixThemesComponent): # Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. text_value: Var[str] - _valid_parents: List[str] = ["DropdownMenuContent", "DropdownMenuSubContent"] + _valid_parents: list[str] = ["DropdownMenuContent", "DropdownMenuSubContent"] # Fired when the item is selected. on_select: EventHandler[no_args_event_spec] diff --git a/reflex/components/radix/themes/components/radio_group.py b/reflex/components/radix/themes/components/radio_group.py index f34c92159..e388ff650 100644 --- a/reflex/components/radix/themes/components/radio_group.py +++ b/reflex/components/radix/themes/components/radio_group.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Literal, Optional, Union +from typing import Literal, Optional, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace @@ -77,7 +77,7 @@ class HighLevelRadioGroup(RadixThemesComponent): """High level wrapper for the RadioGroup component.""" # The items of the radio group. - items: Var[List[str]] + items: Var[list[str]] # The direction of the radio group. direction: Var[LiteralFlexDirection] = LiteralVar.create("row") @@ -118,7 +118,7 @@ class HighLevelRadioGroup(RadixThemesComponent): @classmethod def create( cls, - items: Var[List[Optional[Union[str, int, float, list, dict, bool]]]], + items: Var[list[Optional[Union[str, int, float, list, dict, bool]]]], **props, ) -> Component: """Create a radio group component. diff --git a/reflex/components/radix/themes/components/radio_group.pyi b/reflex/components/radix/themes/components/radio_group.pyi index bb3082545..e3368b91f 100644 --- a/reflex/components/radix/themes/components/radio_group.pyi +++ b/reflex/components/radix/themes/components/radio_group.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints @@ -221,7 +221,7 @@ class HighLevelRadioGroup(RadixThemesComponent): def create( # type: ignore cls, *children, - items: Optional[Union[List[str], Var[List[str]]]] = None, + items: Optional[Union[Var[list[str]], list[str]]] = None, direction: Optional[ Union[ Literal["column", "column-reverse", "row", "row-reverse"], @@ -373,7 +373,7 @@ class RadioGroup(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[List[str], Var[List[str]]]] = None, + items: Optional[Union[Var[list[str]], list[str]]] = None, direction: Optional[ Union[ Literal["column", "column-reverse", "row", "row-reverse"], diff --git a/reflex/components/radix/themes/components/segmented_control.py b/reflex/components/radix/themes/components/segmented_control.py index f2dd9dc7c..61bcb1785 100644 --- a/reflex/components/radix/themes/components/segmented_control.py +++ b/reflex/components/radix/themes/components/segmented_control.py @@ -3,7 +3,7 @@ from __future__ import annotations from types import SimpleNamespace -from typing import List, Literal, Tuple, Union +from typing import Literal, Tuple, Union from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler @@ -13,8 +13,8 @@ from ..base import LiteralAccentColor, RadixThemesComponent def on_value_change( - value: Var[Union[str, List[str]]], -) -> Tuple[Var[Union[str, List[str]]]]: + value: Var[Union[str, list[str]]], +) -> Tuple[Var[Union[str, list[str]]]]: """Handle the on_value_change event. Args: @@ -47,10 +47,10 @@ class SegmentedControlRoot(RadixThemesComponent): radius: Var[Literal["none", "small", "medium", "large", "full"]] # The default value of the segmented control. - default_value: Var[Union[str, List[str]]] + default_value: Var[Union[str, list[str]]] # The current value of the segmented control. - value: Var[Union[str, List[str]]] + value: Var[Union[str, list[str]]] # Handles the `onChange` event for the SegmentedControl component. on_change: EventHandler[on_value_change] @@ -66,7 +66,7 @@ class SegmentedControlItem(RadixThemesComponent): # The value of the item. value: Var[str] - _valid_parents: List[str] = ["SegmentedControlRoot"] + _valid_parents: list[str] = ["SegmentedControlRoot"] class SegmentedControl(SimpleNamespace): diff --git a/reflex/components/radix/themes/components/segmented_control.pyi b/reflex/components/radix/themes/components/segmented_control.pyi index 7631d9a36..8192b1125 100644 --- a/reflex/components/radix/themes/components/segmented_control.pyi +++ b/reflex/components/radix/themes/components/segmented_control.pyi @@ -4,7 +4,7 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload +from typing import Any, Dict, Literal, Optional, Tuple, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventType @@ -14,8 +14,8 @@ from reflex.vars.base import Var from ..base import RadixThemesComponent def on_value_change( - value: Var[Union[str, List[str]]], -) -> Tuple[Var[Union[str, List[str]]]]: ... + value: Var[Union[str, list[str]]], +) -> Tuple[Var[Union[str, list[str]]]]: ... class SegmentedControlRoot(RadixThemesComponent): @overload @@ -109,9 +109,9 @@ class SegmentedControlRoot(RadixThemesComponent): ] ] = None, default_value: Optional[ - Union[List[str], Var[Union[List[str], str]], str] + Union[Var[Union[list[str], str]], list[str], str] ] = None, - value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, + value: Optional[Union[Var[Union[list[str], str]], list[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -120,7 +120,7 @@ class SegmentedControlRoot(RadixThemesComponent): custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[EventType[()]] = None, on_change: Optional[ - Union[EventType[()], EventType[Union[str, List[str]]]] + Union[EventType[()], EventType[Union[str, list[str]]]] ] = None, on_click: Optional[EventType[()]] = None, on_context_menu: Optional[EventType[()]] = None, diff --git a/reflex/components/radix/themes/components/select.py b/reflex/components/radix/themes/components/select.py index cef91eabf..b4819fb97 100644 --- a/reflex/components/radix/themes/components/select.py +++ b/reflex/components/radix/themes/components/select.py @@ -1,6 +1,6 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import List, Literal, Union +from typing import Literal, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace @@ -68,7 +68,7 @@ class SelectTrigger(RadixThemesComponent): # The placeholder of the select trigger placeholder: Var[str] - _valid_parents: List[str] = ["SelectRoot"] + _valid_parents: list[str] = ["SelectRoot"] _memoization_mode = MemoizationMode(recursive=False) @@ -117,7 +117,7 @@ class SelectGroup(RadixThemesComponent): tag = "Select.Group" - _valid_parents: List[str] = ["SelectContent"] + _valid_parents: list[str] = ["SelectContent"] class SelectItem(RadixThemesComponent): @@ -131,7 +131,7 @@ class SelectItem(RadixThemesComponent): # Whether the select item is disabled disabled: Var[bool] - _valid_parents: List[str] = ["SelectGroup", "SelectContent"] + _valid_parents: list[str] = ["SelectGroup", "SelectContent"] class SelectLabel(RadixThemesComponent): @@ -139,7 +139,7 @@ class SelectLabel(RadixThemesComponent): tag = "Select.Label" - _valid_parents: List[str] = ["SelectGroup"] + _valid_parents: list[str] = ["SelectGroup"] class SelectSeparator(RadixThemesComponent): @@ -152,7 +152,7 @@ class HighLevelSelect(SelectRoot): """High level wrapper for the Select component.""" # The items of the select. - items: Var[List[str]] + items: Var[list[str]] # The placeholder of the select. placeholder: Var[str] @@ -179,7 +179,7 @@ class HighLevelSelect(SelectRoot): position: Var[Literal["item-aligned", "popper"]] @classmethod - def create(cls, items: Union[List[str], Var[List[str]]], **props) -> Component: + def create(cls, items: Union[list[str], Var[list[str]]], **props) -> Component: """Create a select component. Args: diff --git a/reflex/components/radix/themes/components/select.pyi b/reflex/components/radix/themes/components/select.pyi index 20b7b1968..f9f4e8c17 100644 --- a/reflex/components/radix/themes/components/select.pyi +++ b/reflex/components/radix/themes/components/select.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints @@ -575,7 +575,7 @@ class HighLevelSelect(SelectRoot): def create( # type: ignore cls, *children, - items: Optional[Union[List[str], Var[List[str]]]] = None, + items: Optional[Union[Var[list[str]], list[str]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ @@ -751,7 +751,7 @@ class Select(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[List[str], Var[List[str]]]] = None, + items: Optional[Union[Var[list[str]], list[str]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ diff --git a/reflex/components/radix/themes/components/slider.py b/reflex/components/radix/themes/components/slider.py index 6acc21497..3d49e6c83 100644 --- a/reflex/components/radix/themes/components/slider.py +++ b/reflex/components/radix/themes/components/slider.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Literal, Optional, Union +from typing import Literal, Optional, Union from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive @@ -42,10 +42,10 @@ class Slider(RadixThemesComponent): radius: Var[Literal["none", "small", "full"]] # The value of the slider when initially rendered. Use when you do not need to control the state of the slider. - default_value: Var[Union[List[Union[float, int]], float, int]] + default_value: Var[Union[list[Union[float, int]], float, int]] # The controlled value of the slider. Must be used in conjunction with onValueChange. - value: Var[List[Union[float, int]]] + value: Var[list[Union[float, int]]] # The name of the slider. Submitted with its owning form as part of a name/value pair. name: Var[str] diff --git a/reflex/components/radix/themes/components/slider.pyi b/reflex/components/radix/themes/components/slider.pyi index 242532d41..c2f344df5 100644 --- a/reflex/components/radix/themes/components/slider.pyi +++ b/reflex/components/radix/themes/components/slider.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.event import EventType, passthrough_event_spec @@ -112,14 +112,14 @@ class Slider(RadixThemesComponent): ] = None, default_value: Optional[ Union[ - List[Union[float, int]], - Var[Union[List[Union[float, int]], float, int]], + Var[Union[float, int, list[Union[float, int]]]], float, int, + list[Union[float, int]], ] ] = None, value: Optional[ - Union[List[Union[float, int]], Var[List[Union[float, int]]]] + Union[Var[list[Union[float, int]]], list[Union[float, int]]] ] = None, name: Optional[Union[Var[str], str]] = None, width: Optional[Union[Var[Optional[str]], str]] = None, diff --git a/reflex/components/radix/themes/components/table.py b/reflex/components/radix/themes/components/table.py index a16002f58..142f07645 100644 --- a/reflex/components/radix/themes/components/table.py +++ b/reflex/components/radix/themes/components/table.py @@ -1,6 +1,6 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import List, Literal +from typing import Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive @@ -27,9 +27,9 @@ class TableHeader(elements.Thead, RadixThemesComponent): tag = "Table.Header" - _invalid_children: List[str] = ["TableBody"] + _invalid_children: list[str] = ["TableBody"] - _valid_parents: List[str] = ["TableRoot"] + _valid_parents: list[str] = ["TableRoot"] class TableRow(elements.Tr, RadixThemesComponent): @@ -40,7 +40,7 @@ class TableRow(elements.Tr, RadixThemesComponent): # The alignment of the row align: Var[Literal["start", "center", "end", "baseline"]] - _invalid_children: List[str] = ["TableBody", "TableHeader", "TableRow"] + _invalid_children: list[str] = ["TableBody", "TableHeader", "TableRow"] class TableColumnHeaderCell(elements.Th, RadixThemesComponent): @@ -57,7 +57,7 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent): # The maximum width of the cell max_width: Var[Responsive[str]] - _invalid_children: List[str] = [ + _invalid_children: list[str] = [ "TableBody", "TableHeader", "TableRow", @@ -72,14 +72,14 @@ class TableBody(elements.Tbody, RadixThemesComponent): tag = "Table.Body" - _invalid_children: List[str] = [ + _invalid_children: list[str] = [ "TableHeader", "TableRowHeaderCell", "TableColumnHeaderCell", "TableCell", ] - _valid_parents: List[str] = ["TableRoot"] + _valid_parents: list[str] = ["TableRoot"] class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent): @@ -96,7 +96,7 @@ class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent): # The maximum width of the cell max_width: Var[Responsive[str]] - _invalid_children: List[str] = [ + _invalid_children: list[str] = [ "TableBody", "TableHeader", "TableRowHeaderCell", @@ -119,7 +119,7 @@ class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent): # The maximum width of the cell max_width: Var[Responsive[str]] - _invalid_children: List[str] = [ + _invalid_children: list[str] = [ "TableBody", "TableHeader", "TableRow", diff --git a/reflex/components/radix/themes/components/tabs.py b/reflex/components/radix/themes/components/tabs.py index 7b5e5f475..8d88bb03c 100644 --- a/reflex/components/radix/themes/components/tabs.py +++ b/reflex/components/radix/themes/components/tabs.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Literal +from typing import Any, Dict, Literal from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive @@ -94,7 +94,7 @@ class TabsTrigger(RadixThemesComponent): # The color of the line under the tab when active. color_scheme: Var[LiteralAccentColor] - _valid_parents: List[str] = ["TabsList"] + _valid_parents: list[str] = ["TabsList"] _memoization_mode = MemoizationMode(recursive=False) diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index 9f6bf672b..d2826ae2f 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -85,7 +85,7 @@ class Axis(Recharts): name: Var[Union[str, int]] # Set the values of axis ticks manually. - ticks: Var[List[Union[str, int]]] + ticks: Var[list[Union[str, int]]] # If set false, no ticks will be drawn. tick: Var[bool] @@ -184,7 +184,7 @@ class ZAxis(Recharts): z_axis_id: Var[Union[str, int]] # The range of axis. Default: [10, 10] - range: Var[List[int]] + range: Var[list[int]] # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. unit: Var[Union[str, int]] @@ -225,7 +225,7 @@ class Brush(Recharts): height: Var[int] # The original data of a LineChart, a BarChart or an AreaChart. - data: Var[List[Any]] + data: Var[list[Any]] # The width of each traveller. Default: 5 traveller_width: Var[int] @@ -357,10 +357,10 @@ class Area(Cartesian): label: Var[bool] # The value which can describle the line, usually calculated internally. - base_line: Var[Union[str, List[Dict[str, Any]]]] + base_line: Var[Union[str, list[Dict[str, Any]]]] # The coordinates of all the points in the area, usually calculated internally. - points: Var[List[Dict[str, Any]]] + points: Var[list[Dict[str, Any]]] # The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order. stack_id: Var[Union[str, int]] @@ -369,7 +369,7 @@ class Area(Cartesian): connect_nulls: Var[bool] # Valid children components - _valid_children: List[str] = ["LabelList"] + _valid_children: list[str] = ["LabelList"] class Bar(Cartesian): @@ -413,13 +413,13 @@ class Bar(Cartesian): 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 - radius: Var[Union[int, List[int]]] + radius: Var[Union[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. # active_bar: Var[Union[bool, Dict[str, Any]]] #noqa: ERA001 # Valid children components - _valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"] + _valid_children: list[str] = ["Cell", "LabelList", "ErrorBar"] class Line(Cartesian): @@ -467,13 +467,13 @@ class Line(Cartesian): unit: Var[Union[str, int]] # The coordinates of all the points in the line, usually calculated internally. - points: Var[List[Dict[str, Any]]] + points: Var[list[Dict[str, Any]]] # The pattern of dashes and gaps used to paint the line. stroke_dasharray: Var[str] # Valid children components - _valid_children: List[str] = ["LabelList", "ErrorBar"] + _valid_children: list[str] = ["LabelList", "ErrorBar"] class Scatter(Recharts): @@ -484,7 +484,7 @@ class Scatter(Recharts): alias = "RechartsScatter" # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle" legend_type: Var[LiteralLegendType] @@ -511,7 +511,7 @@ class Scatter(Recharts): fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) # Valid children components. - _valid_children: List[str] = ["LabelList", "ErrorBar"] + _valid_children: list[str] = ["LabelList", "ErrorBar"] # If set false, animation of bar will be disabled. Default: True in CSR, False in SSR is_animation_active: Var[bool] @@ -558,7 +558,7 @@ class Funnel(Recharts): alias = "RechartsFunnel" # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The key or getter of a group of data which should be unique in a FunnelChart. data_key: Var[Union[str, int]] @@ -585,10 +585,10 @@ class Funnel(Recharts): stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3)) # The coordinates of all the trapezoids in the funnel, usually calculated internally. - trapezoids: Var[List[Dict[str, Any]]] + trapezoids: Var[list[Dict[str, Any]]] # Valid children components - _valid_children: List[str] = ["LabelList", "Cell"] + _valid_children: list[str] = ["LabelList", "Cell"] # The customized event handler of animation start on_animation_start: EventHandler[no_args_event_spec] @@ -683,10 +683,10 @@ class ReferenceLine(Reference): stroke_width: Var[Union[str, int]] # Valid children components - _valid_children: List[str] = ["Label"] + _valid_children: list[str] = ["Label"] # Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine. - segment: List[Any] = [] + segment: list[Any] = [] class ReferenceDot(Reference): @@ -712,7 +712,7 @@ class ReferenceDot(Reference): stroke: Var[Union[str, Color]] # Valid children components - _valid_children: List[str] = ["Label"] + _valid_children: list[str] = ["Label"] # The customized event handler of click on the component in this chart on_click: EventHandler[no_args_event_spec] @@ -780,7 +780,7 @@ class ReferenceArea(Recharts): is_front: Var[bool] # Valid children components - _valid_children: List[str] = ["Label"] + _valid_children: list[str] = ["Label"] class Grid(Recharts): @@ -813,10 +813,10 @@ class CartesianGrid(Grid): vertical: Var[bool] # The x-coordinates in pixel values of all vertical lines. Default: [] - vertical_points: Var[List[Union[str, int]]] + vertical_points: Var[list[Union[str, int]]] # The x-coordinates in pixel values of all vertical lines. Default: [] - horizontal_points: Var[List[Union[str, int]]] + horizontal_points: Var[list[Union[str, int]]] # The background of grid. fill: Var[Union[str, Color]] diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi index 21edbddb5..2ad94b6d3 100644 --- a/reflex/components/recharts/cartesian.pyi +++ b/reflex/components/recharts/cartesian.pyi @@ -100,7 +100,7 @@ class Axis(Recharts): unit: Optional[Union[Var[Union[int, str]], int, str]] = None, name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, @@ -281,7 +281,7 @@ class XAxis(Axis): unit: Optional[Union[Var[Union[int, str]], int, str]] = None, name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, @@ -465,7 +465,7 @@ class YAxis(Axis): unit: Optional[Union[Var[Union[int, str]], int, str]] = None, name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, @@ -562,7 +562,7 @@ class ZAxis(Recharts): *children, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, z_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, - range: Optional[Union[List[int], Var[List[int]]]] = None, + range: Optional[Union[Var[list[int]], list[int]]] = None, unit: Optional[Union[Var[Union[int, str]], int, str]] = None, name: Optional[Union[Var[Union[int, str]], int, str]] = None, scale: Optional[ @@ -665,7 +665,7 @@ class Brush(Recharts): y: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None, height: Optional[Union[Var[int], int]] = None, - data: Optional[Union[List[Any], Var[List[Any]]]] = None, + data: Optional[Union[Var[list[Any]], list[Any]]] = None, traveller_width: Optional[Union[Var[int], int]] = None, gap: Optional[Union[Var[int], int]] = None, start_index: Optional[Union[Var[int], int]] = None, @@ -886,9 +886,9 @@ class Area(Cartesian): ] = None, label: Optional[Union[Var[bool], bool]] = None, base_line: Optional[ - Union[List[Dict[str, Any]], Var[Union[List[Dict[str, Any]], str]], str] + Union[Var[Union[list[Dict[str, Any]], str]], list[Dict[str, Any]], str] ] = None, - points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + points: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, stack_id: Optional[Union[Var[Union[int, str]], int, str]] = None, connect_nulls: Optional[Union[Var[bool], bool]] = None, layout: Optional[ @@ -1034,7 +1034,7 @@ class Bar(Cartesian): name: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, max_bar_size: Optional[Union[Var[int], int]] = None, - radius: Optional[Union[List[int], Var[Union[List[int], int]], int]] = None, + radius: Optional[Union[Var[Union[int, list[int]]], int, list[int]]] = None, layout: Optional[ Union[ Literal["horizontal", "vertical"], @@ -1216,7 +1216,7 @@ class Line(Cartesian): hide: Optional[Union[Var[bool], bool]] = None, connect_nulls: Optional[Union[Var[bool], bool]] = None, unit: Optional[Union[Var[Union[int, str]], int, str]] = None, - points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + points: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, stroke_dasharray: Optional[Union[Var[str], str]] = None, layout: Optional[ Union[ @@ -1348,7 +1348,7 @@ class Scatter(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, legend_type: Optional[ Union[ Literal[ @@ -1483,7 +1483,7 @@ class Funnel(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, name_key: Optional[Union[Var[str], str]] = None, legend_type: Optional[ @@ -1529,7 +1529,7 @@ class Funnel(Recharts): ] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, trapezoids: Optional[ - Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] + Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, @@ -1720,7 +1720,7 @@ class ReferenceLine(Reference): y: Optional[Union[Var[Union[int, str]], int, str]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[Union[int, str]], int, str]] = None, - segment: Optional[List[Any]] = None, + segment: Optional[list[Any]] = None, x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ @@ -1996,10 +1996,10 @@ class CartesianGrid(Grid): horizontal: Optional[Union[Var[bool], bool]] = None, vertical: Optional[Union[Var[bool], bool]] = None, vertical_points: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, horizontal_points: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py index 3e9df4143..419894176 100644 --- a/reflex/components/recharts/charts.py +++ b/reflex/components/recharts/charts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Union +from typing import Any, Dict, Union from reflex.components.component import Component from reflex.components.recharts.general import ResponsiveContainer @@ -104,7 +104,7 @@ class CategoricalChartBase(ChartBase): """A component that wraps a Categorical Recharts charts.""" # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. margin: Var[Dict[str, Any]] @@ -133,7 +133,7 @@ class AreaChart(CategoricalChartBase): base_value: Var[Union[int, LiteralComposedChartBaseValue]] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -174,7 +174,7 @@ class BarChart(CategoricalChartBase): reverse_stack_order: Var[bool] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -196,7 +196,7 @@ class LineChart(CategoricalChartBase): alias = "RechartsLineChart" # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -233,7 +233,7 @@ class ComposedChart(CategoricalChartBase): reverse_stack_order: Var[bool] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "XAxis", "YAxis", "ReferenceArea", @@ -260,7 +260,7 @@ class PieChart(ChartBase): margin: Var[Dict[str, Any]] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -290,7 +290,7 @@ class RadarChart(ChartBase): alias = "RechartsRadarChart" # The source data, in which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. Default: {"top": 0, "right": 0, "left": 0, "bottom": 0} margin: Var[Dict[str, Any]] @@ -314,7 +314,7 @@ class RadarChart(ChartBase): outer_radius: Var[Union[int, str]] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -344,7 +344,7 @@ class RadialBarChart(ChartBase): alias = "RechartsRadialBarChart" # The source data which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "left": 5 "bottom": 5} margin: Var[Dict[str, Any]] @@ -377,7 +377,7 @@ class RadialBarChart(ChartBase): bar_size: Var[int] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "PolarAngleAxis", "PolarRadiusAxis", "PolarGrid", @@ -398,7 +398,7 @@ class ScatterChart(ChartBase): margin: Var[Dict[str, Any]] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "XAxis", "YAxis", "ZAxis", @@ -447,7 +447,7 @@ class FunnelChart(ChartBase): stroke: Var[Union[str, Color]] # Valid children components - _valid_children: List[str] = ["Legend", "GraphingTooltip", "Funnel"] + _valid_children: list[str] = ["Legend", "GraphingTooltip", "Funnel"] class Treemap(RechartsCharts): @@ -464,7 +464,7 @@ class Treemap(RechartsCharts): height: Var[Union[str, int]] = Var.create("100%") # data of treemap. Array - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The key of a group of data which should be unique in a treemap. String | Number. Default: "value" data_key: Var[Union[str, int]] diff --git a/reflex/components/recharts/charts.pyi b/reflex/components/recharts/charts.pyi index a02ea5a8d..8eb2e4cd2 100644 --- a/reflex/components/recharts/charts.pyi +++ b/reflex/components/recharts/charts.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.constants.colors import Color from reflex.event import EventType @@ -72,7 +72,7 @@ class CategoricalChartBase(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ @@ -157,7 +157,7 @@ class AreaChart(CategoricalChartBase): int, ] ] = None, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ @@ -247,7 +247,7 @@ class BarChart(CategoricalChartBase): ] ] = None, reverse_stack_order: Optional[Union[Var[bool], bool]] = None, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ @@ -324,7 +324,7 @@ class LineChart(CategoricalChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ @@ -413,7 +413,7 @@ class ComposedChart(CategoricalChartBase): bar_gap: Optional[Union[Var[int], int]] = None, bar_size: Optional[Union[Var[int], int]] = None, reverse_stack_order: Optional[Union[Var[bool], bool]] = None, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ @@ -557,7 +557,7 @@ class RadarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -614,7 +614,7 @@ class RadialBarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -802,7 +802,7 @@ class Treemap(RechartsCharts): *children, width: Optional[Union[Var[Union[int, str]], int, str]] = None, height: Optional[Union[Var[Union[int, str]], int, str]] = None, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, name_key: Optional[Union[Var[str], str]] = None, aspect_ratio: Optional[Union[Var[int], int]] = None, diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py index 4b8c527d3..787daf282 100644 --- a/reflex/components/recharts/general.py +++ b/reflex/components/recharts/general.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Union +from typing import Any, Dict, Union from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color @@ -49,7 +49,7 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): on_resize: EventHandler[no_args_event_spec] # Valid children components - _valid_children: List[str] = [ + _valid_children: list[str] = [ "AreaChart", "BarChart", "LineChart", @@ -92,7 +92,7 @@ class Legend(Recharts): icon_type: Var[LiteralIconType] # The source data of the content to be displayed in the legend, usually calculated internally. Default: [] - payload: Var[List[Dict[str, Any]]] + payload: Var[list[Dict[str, Any]]] # The width of chart container, usually calculated internally. chart_width: Var[int] diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi index f84cd891b..455b05d80 100644 --- a/reflex/components/recharts/general.pyi +++ b/reflex/components/recharts/general.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color @@ -131,7 +131,7 @@ class Legend(Recharts): ] ] = None, payload: Optional[ - Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]] + Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]] ] = None, chart_width: Optional[Union[Var[int], int]] = None, chart_height: Optional[Union[Var[int], int]] = None, diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index 77aa1ef5e..0f593c521 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Union +from typing import Any, Dict, Union from reflex.constants import EventTriggers from reflex.constants.colors import Color @@ -28,7 +28,7 @@ class Pie(Recharts): alias = "RechartsPie" # The source data which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The key of each sector's value. data_key: Var[Union[str, int]] @@ -70,10 +70,10 @@ class Pie(Recharts): label_line: Var[bool] # The index of active sector in Pie, this option can be changed in mouse event handlers. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # Valid children components - _valid_children: List[str] = ["Cell", "LabelList", "Bare"] + _valid_children: list[str] = ["Cell", "LabelList", "Bare"] # Stoke color. Default: rx.color("accent", 9) stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) @@ -125,7 +125,7 @@ class Radar(Recharts): data_key: Var[Union[str, int]] # The coordinates of all the vertices of the radar shape, like [{ x, y }]. - points: Var[List[Dict[str, Any]]] + points: Var[list[Dict[str, Any]]] # If false set, dots will not be drawn. Default: True dot: Var[bool] @@ -158,7 +158,7 @@ class Radar(Recharts): animation_easing: Var[LiteralAnimationEasing] # Valid children components - _valid_children: List[str] = ["LabelList"] + _valid_children: list[str] = ["LabelList"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -180,7 +180,7 @@ class RadialBar(Recharts): alias = "RechartsRadialBar" # The source data which each element is an object. - data: Var[List[Dict[str, Any]]] + data: Var[list[Dict[str, Any]]] # The key of a group of data which should be unique to show the meaning of angle axis. data_key: Var[Union[str, int]] @@ -210,7 +210,7 @@ class RadialBar(Recharts): animation_easing: Var[LiteralAnimationEasing] # Valid children components - _valid_children: List[str] = ["Cell", "LabelList"] + _valid_children: list[str] = ["Cell", "LabelList"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -262,7 +262,7 @@ class PolarAngleAxis(Recharts): tick: Var[Union[bool, Dict[str, Any]]] # The array of every tick's value and angle. - ticks: Var[List[Dict[str, Any]]] + ticks: Var[list[Dict[str, Any]]] # The orientation of axis text. Default: "outer" orientation: Var[str] @@ -274,7 +274,7 @@ class PolarAngleAxis(Recharts): allow_duplicated_category: Var[bool] # Valid children components. - _valid_children: List[str] = ["Label"] + _valid_children: list[str] = ["Label"] # The customized event handler of click on the ticks of this axis. on_click: EventHandler[no_args_event_spec] @@ -321,10 +321,10 @@ class PolarGrid(Recharts): outer_radius: Var[int] # The array of every line grid's angle. - polar_angles: Var[List[int]] + polar_angles: Var[list[int]] # The array of every line grid's radius. - polar_radius: Var[List[int]] + polar_radius: Var[list[int]] # The type of polar grids. 'polygon' | 'circle'. Default: "polygon" grid_type: Var[LiteralGridType] @@ -333,7 +333,7 @@ class PolarGrid(Recharts): stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) # Valid children components - _valid_children: List[str] = ["RadarChart", "RadiarBarChart"] + _valid_children: list[str] = ["RadarChart", "RadiarBarChart"] class PolarRadiusAxis(Recharts): @@ -377,10 +377,10 @@ class PolarRadiusAxis(Recharts): scale: Var[LiteralScale] # Valid children components - _valid_children: List[str] = ["Label"] + _valid_children: list[str] = ["Label"] # The domain of the polar radius axis, specifying the minimum and maximum values. Default: [0, "auto"] - domain: Var[List[Union[int, str]]] + domain: Var[list[Union[int, str]]] # The stroke color of axis. Default: rx.color("gray", 10) stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi index 8f08aed16..afd66a69e 100644 --- a/reflex/components/recharts/polar.pyi +++ b/reflex/components/recharts/polar.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.constants.colors import Color from reflex.event import EventType @@ -19,7 +19,7 @@ class Pie(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -138,7 +138,7 @@ class Radar(Recharts): cls, *children, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, - points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + points: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, dot: Optional[Union[Var[bool], bool]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill: Optional[Union[Var[str], str]] = None, @@ -231,7 +231,7 @@ class RadialBar(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, min_angle: Optional[Union[Var[int], int]] = None, legend_type: Optional[ @@ -346,7 +346,7 @@ class PolarAngleAxis(Recharts): tick: Optional[ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - ticks: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + ticks: Optional[Union[Var[list[Dict[str, Any]]], list[Dict[str, Any]]]] = None, orientation: Optional[Union[Var[str], str]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, @@ -420,8 +420,8 @@ class PolarGrid(Recharts): cy: Optional[Union[Var[int], int]] = None, inner_radius: Optional[Union[Var[int], int]] = None, outer_radius: Optional[Union[Var[int], int]] = None, - polar_angles: Optional[Union[List[int], Var[List[int]]]] = None, - polar_radius: Optional[Union[List[int], Var[List[int]]]] = None, + polar_angles: Optional[Union[Var[list[int]], list[int]]] = None, + polar_radius: Optional[Union[Var[list[int]], list[int]]] = None, grid_type: Optional[ Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]] ] = None, @@ -543,7 +543,7 @@ class PolarRadiusAxis(Recharts): ] ] = None, domain: Optional[ - Union[List[Union[int, str]], Var[List[Union[int, str]]]] + Union[Var[list[Union[int, str]]], list[Union[int, str]]] ] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, diff --git a/reflex/components/suneditor/editor.py b/reflex/components/suneditor/editor.py index 3edf27545..6ff63b35e 100644 --- a/reflex/components/suneditor/editor.py +++ b/reflex/components/suneditor/editor.py @@ -3,7 +3,7 @@ from __future__ import annotations import enum -from typing import Any, Dict, List, Literal, Optional, Tuple, Union +from typing import Any, Dict, Literal, Optional, Tuple, Union from reflex.base import Base from reflex.components.component import Component, NoSSRComponent @@ -65,7 +65,7 @@ class EditorOptions(Base): rtl: Optional[bool] = None # List of buttons to use in the toolbar. - button_list: Optional[List[Union[List[str], str]]] + button_list: Optional[list[Union[list[str], str]]] def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]: @@ -109,7 +109,7 @@ class Editor(NoSSRComponent): is_default = True - lib_dependencies: List[str] = ["suneditor"] + lib_dependencies: list[str] = ["suneditor"] # Language of the editor. # Alternatively to a string, a dict of your language can be passed to this prop. diff --git a/reflex/components/suneditor/editor.pyi b/reflex/components/suneditor/editor.pyi index f5fb1b830..9ec253426 100644 --- a/reflex/components/suneditor/editor.pyi +++ b/reflex/components/suneditor/editor.pyi @@ -4,7 +4,7 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ import enum -from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload +from typing import Any, Dict, Literal, Optional, Tuple, Union, overload from reflex.base import Base from reflex.components.component import NoSSRComponent @@ -42,7 +42,7 @@ class EditorOptions(Base): default_tag: Optional[str] mode: Optional[str] rtl: Optional[bool] - button_list: Optional[List[Union[List[str], str]]] + button_list: Optional[list[Union[list[str], str]]] def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]: ... def on_paste_spec( diff --git a/reflex/components/tags/match_tag.py b/reflex/components/tags/match_tag.py index 01eedb296..be1126446 100644 --- a/reflex/components/tags/match_tag.py +++ b/reflex/components/tags/match_tag.py @@ -1,7 +1,7 @@ """Tag to conditionally match cases.""" import dataclasses -from typing import Any, List +from typing import Any from reflex.components.tags.tag import Tag from reflex.vars.base import Var @@ -15,7 +15,7 @@ class MatchTag(Tag): cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True)) # The list of match cases to be matched. - match_cases: List[Any] = dataclasses.field(default_factory=list) + match_cases: list[Any] = dataclasses.field(default_factory=list) # The catchall case to match. default: Any = dataclasses.field(default=Var.create(None)) diff --git a/reflex/components/tags/tag.py b/reflex/components/tags/tag.py index 515d9e05f..18a81b1a7 100644 --- a/reflex/components/tags/tag.py +++ b/reflex/components/tags/tag.py @@ -44,10 +44,10 @@ class Tag: contents: str = "" # Special props that aren't key value pairs. - special_props: List[Var] = dataclasses.field(default_factory=list) + special_props: list[Var] = dataclasses.field(default_factory=list) # The children components. - children: List[Any] = dataclasses.field(default_factory=list) + children: list[Any] = dataclasses.field(default_factory=list) def __post_init__(self): """Post initialize the tag.""" diff --git a/reflex/config.py b/reflex/config.py index 0d48057d7..17e7aa813 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -24,7 +24,6 @@ from typing import ( Callable, Dict, Generic, - List, Optional, Set, TypeVar, @@ -703,10 +702,10 @@ class EnvironmentVariables: REFLEX_USE_TURBOPACK: EnvVar[bool] = env_var(True) # Additional paths to include in the hot reload. Separated by a colon. - REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[List[Path]] = env_var([]) + REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[list[Path]] = env_var([]) # Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon. - REFLEX_HOT_RELOAD_EXCLUDE_PATHS: EnvVar[List[Path]] = env_var([]) + REFLEX_HOT_RELOAD_EXCLUDE_PATHS: EnvVar[list[Path]] = env_var([]) environment = EnvironmentVariables() @@ -791,7 +790,7 @@ class Config(Base): static_page_generation_timeout: int = 60 # List of origins that are allowed to connect to the backend API. - cors_allowed_origins: List[str] = ["*"] + cors_allowed_origins: list[str] = ["*"] # Tailwind config. tailwind: Optional[Dict[str, Any]] = {"plugins": ["@tailwindcss/typography"]} @@ -806,7 +805,7 @@ class Config(Base): react_strict_mode: bool = True # Additional frontend packages to install. - frontend_packages: List[str] = [] + frontend_packages: list[str] = [] # The hosting service backend URL. cp_backend_url: str = Hosting.HOSTING_SERVICE diff --git a/reflex/event.py b/reflex/event.py index 6552eb079..12b9690a5 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -451,7 +451,7 @@ class EventChain(EventActionsMixin): # If the input is a list of event handlers, create an event chain. if isinstance(value, List): - events: List[Union[EventSpec, EventVar]] = [] + events: list[Union[EventSpec, EventVar]] = [] for v in value: if isinstance(v, (EventHandler, EventSpec)): # Call the event handler to get the event. @@ -1885,7 +1885,7 @@ LAMBDA_OR_STATE = TypeAliasType( type_params=(ARGS,), ) -ItemOrList = V | List[V] +ItemOrList = V | list[V] BASIC_EVENT_TYPES = TypeAliasType( "BASIC_EVENT_TYPES", EventSpec | EventHandler | Var[Any], type_params=() diff --git a/reflex/experimental/layout.py b/reflex/experimental/layout.py index d54e87f8b..62540b502 100644 --- a/reflex/experimental/layout.py +++ b/reflex/experimental/layout.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from reflex import color, cond from reflex.components.base.fragment import Fragment @@ -64,7 +64,7 @@ class Sidebar(Box, MemoizationLeaf): } ) - def add_hooks(self) -> List[Var]: + def add_hooks(self) -> list[Var]: """Get the hooks to render. Returns: diff --git a/reflex/experimental/layout.pyi b/reflex/experimental/layout.pyi index 33a12b82c..061d4b9df 100644 --- a/reflex/experimental/layout.pyi +++ b/reflex/experimental/layout.pyi @@ -3,7 +3,7 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex import color from reflex.components.base.fragment import Fragment @@ -261,7 +261,7 @@ class Sidebar(Box, MemoizationLeaf): ... def add_style(self) -> dict[str, Any] | None: ... - def add_hooks(self) -> List[Var]: ... + def add_hooks(self) -> list[Var]: ... class StatefulSidebar(ComponentState): open: bool @@ -287,7 +287,7 @@ class DrawerSidebar(DrawerRoot): ] = None, dismissible: Optional[Union[Var[bool], bool]] = None, handle_only: Optional[Union[Var[bool], bool]] = None, - snap_points: Optional[List[Union[float, str]]] = None, + snap_points: Optional[list[Union[float, str]]] = None, fade_from_index: Optional[Union[Var[int], int]] = None, scroll_lock_timeout: Optional[Union[Var[int], int]] = None, prevent_scroll_restoration: Optional[Union[Var[bool], bool]] = None, diff --git a/reflex/reflex.py b/reflex/reflex.py index 9c94a3743..c0403c05d 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -4,7 +4,7 @@ from __future__ import annotations import atexit from pathlib import Path -from typing import List, Optional +from typing import Optional import typer import typer.core @@ -493,13 +493,13 @@ def deploy( "--app-id", help="The ID of the App to deploy over.", ), - regions: List[str] = typer.Option( + regions: list[str] = typer.Option( [], "-r", "--region", help="The regions to deploy to. `reflex cloud regions` For multiple envs, repeat this option, e.g. --region sjc --region iad", ), - envs: List[str] = typer.Option( + envs: list[str] = typer.Option( [], "--env", help="The environment variables to set: =. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.", diff --git a/reflex/state.py b/reflex/state.py index 2689ba910..56e190adc 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -26,7 +26,6 @@ from typing import ( Callable, ClassVar, Dict, - List, Optional, Sequence, Set, @@ -707,7 +706,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return getattr(cls, unique_var_name) @classmethod - def _mixins(cls) -> List[Type]: + def _mixins(cls) -> list[Type]: """Get the mixin classes of the state. Returns: @@ -1194,7 +1193,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return inner_func def arglist_factory(param: str): - def inner_func(self: BaseState) -> List[str]: + def inner_func(self: BaseState) -> list[str]: return self.router.page.params.get(param, []) return inner_func @@ -1697,7 +1696,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): return StateUpdate() event_specs_correct_type = cast( - Union[List[Union[EventSpec, EventHandler]], None], + Union[list[Union[EventSpec, EventHandler]], None], [event_specs] if isinstance(event_specs, EventSpec) else event_specs, ) fixed_events = fix_events( @@ -2755,7 +2754,7 @@ class StateUpdate: delta: Delta = dataclasses.field(default_factory=dict) # Events to be added to the event queue. - events: List[Event] = dataclasses.field(default_factory=list) + events: list[Event] = dataclasses.field(default_factory=list) # Whether this is the final state update for the event. final: bool = True diff --git a/reflex/testing.py b/reflex/testing.py index e463ddea7..bea379f96 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -26,7 +26,6 @@ from typing import ( AsyncIterator, Callable, Coroutine, - List, Optional, Type, TypeVar, @@ -198,7 +197,7 @@ class AppHarness: f"{self.app_name}___{self.app_name}___" + state_cls_name ) - def get_full_state_name(self, path: List[str]) -> str: + def get_full_state_name(self, path: list[str]) -> str: """Get the full state name for the given state class name. Args: @@ -596,7 +595,7 @@ class AppHarness: driver_clz: Optional[Type["WebDriver"]] = None, driver_kwargs: dict[str, Any] | None = None, driver_options: ArgOptions | None = None, - driver_option_args: List[str] | None = None, + driver_option_args: list[str] | None = None, driver_option_capabilities: dict[str, Any] | None = None, ) -> "WebDriver": """Get a selenium webdriver instance pointed at the app. diff --git a/reflex/utils/format.py b/reflex/utils/format.py index 214c845f8..3361ca120 100644 --- a/reflex/utils/format.py +++ b/reflex/utils/format.py @@ -6,7 +6,7 @@ import inspect import json import os import re -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union from reflex import constants from reflex.constants.state import FRONTEND_EVENT_STATE @@ -337,7 +337,7 @@ def format_route(route: str, format_case: bool = True) -> str: def format_match( cond: str | Var, - match_cases: List[List[Var]], + match_cases: list[list[Var]], default: Var, ) -> str: """Format a match expression whose return type is a Var. diff --git a/reflex/utils/imports.py b/reflex/utils/imports.py index 66ae4b023..492f36655 100644 --- a/reflex/utils/imports.py +++ b/reflex/utils/imports.py @@ -4,7 +4,7 @@ from __future__ import annotations import dataclasses from collections import defaultdict -from typing import DefaultDict, Dict, List, Optional, Tuple, Union +from typing import DefaultDict, Dict, Optional, Tuple, Union def merge_imports( @@ -18,7 +18,7 @@ def merge_imports( Returns: The merged import dicts. """ - all_imports: DefaultDict[str, List[ImportVar]] = defaultdict(list) + all_imports: DefaultDict[str, list[ImportVar]] = defaultdict(list) for import_dict in imports: for lib, fields in ( import_dict if isinstance(import_dict, tuple) else import_dict.items() @@ -131,7 +131,7 @@ class ImportVar: return self.tag or "" -ImportTypes = Union[str, ImportVar, List[Union[str, ImportVar]], List[ImportVar]] +ImportTypes = Union[str, ImportVar, list[Union[str, ImportVar]], list[ImportVar]] ImportDict = Dict[str, ImportTypes] -ParsedImportDict = Dict[str, List[ImportVar]] +ParsedImportDict = Dict[str, list[ImportVar]] ImmutableParsedImportDict = Tuple[Tuple[str, Tuple[ImportVar, ...]], ...] diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 3cd65a7eb..c969e12c9 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -23,7 +23,7 @@ import zipfile from datetime import datetime from pathlib import Path from types import ModuleType -from typing import Any, Callable, List, NamedTuple, Optional +from typing import Any, Callable, NamedTuple, Optional from urllib.parse import urlparse import httpx @@ -886,7 +886,7 @@ def init_reflex_json(project_hash: int | None): def update_next_config( - export: bool = False, transpile_packages: Optional[List[str]] = None + export: bool = False, transpile_packages: Optional[list[str]] = None ): """Update Next.js config from Reflex config. @@ -908,7 +908,7 @@ def update_next_config( def _update_next_config( - config: Config, export: bool = False, transpile_packages: Optional[List[str]] = None + config: Config, export: bool = False, transpile_packages: Optional[list[str]] = None ): next_config = { "basePath": config.frontend_path or "", diff --git a/reflex/utils/processes.py b/reflex/utils/processes.py index a0c13300d..5eefa3127 100644 --- a/reflex/utils/processes.py +++ b/reflex/utils/processes.py @@ -10,7 +10,7 @@ import signal import subprocess from concurrent import futures from pathlib import Path -from typing import Callable, Generator, List, Optional, Tuple, Union +from typing import Callable, Generator, Optional, Tuple, Union import psutil import typer @@ -335,7 +335,7 @@ def show_status( status.update(f"{message} {line}") -def show_progress(message: str, process: subprocess.Popen, checkpoints: List[str]): +def show_progress(message: str, process: subprocess.Popen, checkpoints: list[str]): """Show a progress bar for a process. Args: diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py index 93c0e89d3..f384dad9d 100644 --- a/reflex/utils/pyi_generator.py +++ b/reflex/utils/pyi_generator.py @@ -431,7 +431,7 @@ def type_to_ast(typ: Any, cls: type) -> ast.AST: # Convert all type arguments recursively arg_nodes = [type_to_ast(arg, cls) for arg in args] - # Special case for single-argument types (like List[T] or Optional[T]) + # Special case for single-argument types (like list[T] or Optional[T]) if len(arg_nodes) == 1: slice_value = arg_nodes[0] else: diff --git a/reflex/utils/serializers.py b/reflex/utils/serializers.py index f8ddaf31c..2feb1abf6 100644 --- a/reflex/utils/serializers.py +++ b/reflex/utils/serializers.py @@ -13,7 +13,6 @@ from pathlib import Path from typing import ( Any, Callable, - List, Literal, Optional, Set, @@ -370,7 +369,7 @@ def serialize_color(color: Color) -> str: with contextlib.suppress(ImportError): from pandas import DataFrame - def format_dataframe_values(df: DataFrame) -> List[List[Any]]: + def format_dataframe_values(df: DataFrame) -> list[list[Any]]: """Format dataframe values to a list of lists. Args: diff --git a/reflex/utils/types.py b/reflex/utils/types.py index 516b70986..69f0afbe3 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -76,7 +76,7 @@ if TYPE_CHECKING: | Callable[[Var, Var, Var, Var, Var, Var, Var], Sequence[Var]] ) else: - ArgsSpec = Callable[..., List[Any]] + ArgsSpec = Callable[..., list[Any]] PrimitiveToAnnotation = { @@ -333,10 +333,10 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None if isinstance(prop, Relationship): type_ = prop.mapper.class_ # TODO: check for nullable? - type_ = List[type_] if prop.uselist else Optional[type_] + type_ = list[type_] if prop.uselist else Optional[type_] return type_ if isinstance(attr, AssociationProxyInstance): - return List[ + return list[ get_attribute_access_type( attr.target_class, attr.remote_attr.key, # type: ignore[attr-defined] @@ -870,7 +870,7 @@ def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> boo for provided_arg in provided_args ) - # Check if the origin of both types is the same (e.g., list for List[int]) + # Check if the origin of both types is the same (e.g., list for list[int]) # This probably should be issubclass instead of == if (provided_type_origin or possible_subclass) != ( accepted_type_origin or possible_superclass diff --git a/reflex/vars/base.py b/reflex/vars/base.py index 89bc86fce..82c235816 100644 --- a/reflex/vars/base.py +++ b/reflex/vars/base.py @@ -103,8 +103,8 @@ class VarSubclassEntry: python_types: Tuple[GenericType, ...] -_var_subclasses: List[VarSubclassEntry] = [] -_var_literal_subclasses: List[Tuple[Type[LiteralVar], VarSubclassEntry]] = [] +_var_subclasses: list[VarSubclassEntry] = [] +_var_literal_subclasses: list[Tuple[Type[LiteralVar], VarSubclassEntry]] = [] @dataclasses.dataclass( @@ -1200,7 +1200,7 @@ class Var(Generic[VAR_TYPE]): @overload @classmethod - def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... + def range(cls, stop: int | NumberVar, /) -> ArrayVar[list[int]]: ... @overload @classmethod @@ -1210,7 +1210,7 @@ class Var(Generic[VAR_TYPE]): end: int | NumberVar, step: int | NumberVar = 1, /, - ) -> ArrayVar[List[int]]: ... + ) -> ArrayVar[list[int]]: ... @classmethod def range( @@ -1218,7 +1218,7 @@ class Var(Generic[VAR_TYPE]): first_endpoint: int | NumberVar, second_endpoint: int | NumberVar | None = None, step: int | NumberVar | None = None, - ) -> ArrayVar[List[int]]: + ) -> ArrayVar[list[int]]: """Create a range of numbers. Args: @@ -1676,7 +1676,7 @@ def figure_out_type(value: Any) -> types.GenericType: if has_args(type_): return type_ if isinstance(value, list): - return List[unionize(*(figure_out_type(v) for v in value))] + return list[unionize(*(figure_out_type(v) for v in value))] if isinstance(value, set): return Set[unionize(*(figure_out_type(v) for v in value))] if isinstance(value, tuple): @@ -1967,7 +1967,7 @@ class ComputedVar(Var[RETURN_TYPE]): fget: Callable[[BASE_STATE], RETURN_TYPE], initial_value: RETURN_TYPE | types.Unset = types.Unset(), cache: bool = True, - deps: Optional[List[Union[str, Var]]] = None, + deps: Optional[list[Union[str, Var]]] = None, auto_deps: bool = True, interval: Optional[Union[int, datetime.timedelta]] = None, backend: bool | None = None, @@ -2031,7 +2031,7 @@ class ComputedVar(Var[RETURN_TYPE]): def _calculate_static_deps( self, - deps: Union[List[Union[str, Var]], dict[str | None, set[str]]] | None = None, + deps: Union[list[Union[str, Var]], dict[str | None, set[str]]] | None = None, ) -> dict[str | None, set[str]]: """Calculate the static dependencies of the computed var from user input or existing dependencies. @@ -2406,7 +2406,7 @@ class ComputedVar(Var[RETURN_TYPE]): return self._fget -class DynamicRouteVar(ComputedVar[Union[str, List[str]]]): +class DynamicRouteVar(ComputedVar[Union[str, list[str]]]): """A ComputedVar that represents a dynamic route.""" pass @@ -2562,7 +2562,7 @@ def computed_var( fget: None = None, initial_value: Any | types.Unset = types.Unset(), cache: bool = True, - deps: Optional[List[Union[str, Var]]] = None, + deps: Optional[list[Union[str, Var]]] = None, auto_deps: bool = True, interval: Optional[Union[datetime.timedelta, int]] = None, backend: bool | None = None, @@ -2575,7 +2575,7 @@ def computed_var( fget: Callable[[BASE_STATE], RETURN_TYPE], initial_value: RETURN_TYPE | types.Unset = types.Unset(), cache: bool = True, - deps: Optional[List[Union[str, Var]]] = None, + deps: Optional[list[Union[str, Var]]] = None, auto_deps: bool = True, interval: Optional[Union[datetime.timedelta, int]] = None, backend: bool | None = None, @@ -2587,7 +2587,7 @@ def computed_var( fget: Callable[[BASE_STATE], Any] | None = None, initial_value: Any | types.Unset = types.Unset(), cache: bool = True, - deps: Optional[List[Union[str, Var]]] = None, + deps: Optional[list[Union[str, Var]]] = None, auto_deps: bool = True, interval: Optional[Union[datetime.timedelta, int]] = None, backend: bool | None = None, @@ -3269,10 +3269,10 @@ class Field(Generic[FIELD_TYPE]): @overload def __get__( - self: Field[List[V]] | Field[Set[V]] | Field[Tuple[V, ...]], + self: Field[list[V]] | Field[Set[V]] | Field[Tuple[V, ...]], instance: None, owner: Any, - ) -> ArrayVar[List[V]]: ... + ) -> ArrayVar[list[V]]: ... @overload def __get__( diff --git a/reflex/vars/object.py b/reflex/vars/object.py index 89479bbc4..b4fc75945 100644 --- a/reflex/vars/object.py +++ b/reflex/vars/object.py @@ -7,7 +7,6 @@ import typing from inspect import isclass from typing import ( Any, - List, Mapping, NoReturn, Tuple, @@ -83,7 +82,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping): args = get_args(self._var_type) if issubclass(fixed_type, Mapping) else () return args[1] if args else Any # pyright: ignore [reportReturnType] - def keys(self) -> ArrayVar[List[str]]: + def keys(self) -> ArrayVar[list[str]]: """Get the keys of the object. Returns: @@ -94,7 +93,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping): @overload def values( self: ObjectVar[Mapping[Any, VALUE_TYPE]], - ) -> ArrayVar[List[VALUE_TYPE]]: ... + ) -> ArrayVar[list[VALUE_TYPE]]: ... @overload def values(self) -> ArrayVar: ... @@ -110,7 +109,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping): @overload def entries( self: ObjectVar[Mapping[Any, VALUE_TYPE]], - ) -> ArrayVar[List[Tuple[str, VALUE_TYPE]]]: ... + ) -> ArrayVar[list[Tuple[str, VALUE_TYPE]]]: ... @overload def entries(self) -> ArrayVar: ... @@ -427,7 +426,7 @@ def object_keys_operation(value: ObjectVar): """ return var_operation_return( js_expression=f"Object.keys({value})", - var_type=List[str], + var_type=list[str], ) @@ -443,7 +442,7 @@ def object_values_operation(value: ObjectVar): """ return var_operation_return( js_expression=f"Object.values({value})", - var_type=List[value._value_type()], + var_type=list[value._value_type()], ) @@ -459,7 +458,7 @@ def object_entries_operation(value: ObjectVar): """ return var_operation_return( js_expression=f"Object.entries({value})", - var_type=List[Tuple[str, value._value_type()]], + var_type=list[Tuple[str, value._value_type()]], ) diff --git a/reflex/vars/sequence.py b/reflex/vars/sequence.py index b8b66d627..32e959bbe 100644 --- a/reflex/vars/sequence.py +++ b/reflex/vars/sequence.py @@ -11,7 +11,6 @@ from typing import ( TYPE_CHECKING, Any, Dict, - List, Literal, NoReturn, Sequence, @@ -253,12 +252,12 @@ class StringVar(Var[STRING_TYPE], python_types=str): return string_contains_operation(self, other) @overload - def split(self, separator: StringVar | str = "") -> ArrayVar[List[str]]: ... + def split(self, separator: StringVar | str = "") -> ArrayVar[list[str]]: ... @overload def split(self, separator: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload] - def split(self, separator: Any = "") -> ArrayVar[List[str]]: + def split(self, separator: Any = "") -> ArrayVar[list[str]]: """Split the string. Args: @@ -810,7 +809,7 @@ class ConcatVarOperation(CachedVarOperation, StringVar[str]): Returns: The name of the var. """ - list_of_strs: List[Union[str, Var]] = [] + list_of_strs: list[Union[str, Var]] = [] last_string = "" for var in self._var_value: if isinstance(var, LiteralStringVar): @@ -1018,9 +1017,9 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)): @overload def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]], + self: ARRAY_VAR_OF_LIST_ELEMENT[list[INNER_ARRAY_VAR]], i: int | NumberVar, - ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ... + ) -> ArrayVar[list[INNER_ARRAY_VAR]]: ... @overload def __getitem__( @@ -1088,7 +1087,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)): @overload @classmethod - def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... + def range(cls, stop: int | NumberVar, /) -> ArrayVar[list[int]]: ... @overload @classmethod @@ -1098,7 +1097,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)): end: int | NumberVar, step: int | NumberVar = 1, /, - ) -> ArrayVar[List[int]]: ... + ) -> ArrayVar[list[int]]: ... @overload @classmethod @@ -1107,7 +1106,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)): first_endpoint: int | NumberVar, second_endpoint: int | NumberVar | None = None, step: int | NumberVar | None = None, - ) -> ArrayVar[List[int]]: ... + ) -> ArrayVar[list[int]]: ... @classmethod def range( @@ -1115,7 +1114,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)): first_endpoint: int | NumberVar, second_endpoint: int | NumberVar | None = None, step: int | NumberVar | None = None, - ) -> ArrayVar[List[int]]: + ) -> ArrayVar[list[int]]: """Create a range of numbers. Args: @@ -1438,7 +1437,7 @@ def string_split_operation(string: StringVar[Any], sep: StringVar | str = ""): The split string. """ return var_operation_return( - js_expression=f"{string}.split({sep})", var_type=List[str] + js_expression=f"{string}.split({sep})", var_type=list[str] ) @@ -1683,7 +1682,7 @@ def array_range_operation( """ return var_operation_return( js_expression=f"Array.from({{ length: Math.ceil(({stop!s} - {start!s}) / {step!s}) }}, (_, i) => {start!s} + i * {step!s})", - var_type=List[int], + var_type=list[int], ) @@ -1749,7 +1748,7 @@ def repeat_array_operation( def map_array_operation( array: ArrayVar[ARRAY_VAR_TYPE], function: FunctionVar, -) -> CustomVarOperationReturn[List[Any]]: +) -> CustomVarOperationReturn[list[Any]]: """Map a function over an array. Args: @@ -1760,7 +1759,7 @@ def map_array_operation( The mapped array. """ return var_operation_return( - js_expression=f"{array}.map({function})", var_type=List[Any] + js_expression=f"{array}.map({function})", var_type=list[Any] ) diff --git a/tests/integration/test_dynamic_routes.py b/tests/integration/test_dynamic_routes.py index 327c5565b..9cdb970ca 100644 --- a/tests/integration/test_dynamic_routes.py +++ b/tests/integration/test_dynamic_routes.py @@ -16,12 +16,10 @@ from .utils import poll_for_navigation def DynamicRoute(): """App for testing dynamic routes.""" - from typing import List - import reflex as rx class DynamicState(rx.State): - order: List[str] = [] + order: list[str] = [] @rx.event def on_load(self): diff --git a/tests/integration/test_event_actions.py b/tests/integration/test_event_actions.py index 707410075..347af6394 100644 --- a/tests/integration/test_event_actions.py +++ b/tests/integration/test_event_actions.py @@ -14,12 +14,12 @@ from reflex.testing import AppHarness, WebDriver def TestEventAction(): """App for testing event_actions.""" - from typing import List, Optional + from typing import Optional import reflex as rx class EventActionState(rx.State): - order: List[str] + order: list[str] def on_click(self, ev): self.order.append(f"on_click:{ev}") diff --git a/tests/integration/test_event_chain.py b/tests/integration/test_event_chain.py index df571e884..c0925eebd 100644 --- a/tests/integration/test_event_chain.py +++ b/tests/integration/test_event_chain.py @@ -16,7 +16,6 @@ def EventChain(): """App with chained event handlers.""" import asyncio import time - from typing import List import reflex as rx @@ -24,7 +23,7 @@ def EventChain(): MANY_EVENTS = 50 class State(rx.State): - event_order: List[str] = [] + event_order: list[str] = [] interim_value: str = "" @rx.event diff --git a/tests/integration/test_form_submit.py b/tests/integration/test_form_submit.py index bdf54173c..69c55c057 100644 --- a/tests/integration/test_form_submit.py +++ b/tests/integration/test_form_submit.py @@ -18,14 +18,14 @@ def FormSubmit(form_component): Args: form_component: The str name of the form component to use. """ - from typing import Dict, List + from typing import Dict import reflex as rx class FormState(rx.State): form_data: Dict = {} - var_options: List[str] = ["option3", "option4"] + var_options: list[str] = ["option3", "option4"] def form_submit(self, form_data: Dict): self.form_data = form_data @@ -78,14 +78,14 @@ def FormSubmitName(form_component): Args: form_component: The str name of the form component to use. """ - from typing import Dict, List + from typing import Dict import reflex as rx class FormState(rx.State): form_data: Dict = {} val: str = "foo" - options: List[str] = ["option1", "option2"] + options: list[str] = ["option1", "option2"] def form_submit(self, form_data: Dict): self.form_data = form_data diff --git a/tests/integration/test_upload.py b/tests/integration/test_upload.py index 471382570..bf1f787fe 100644 --- a/tests/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -19,7 +19,7 @@ from .utils import poll_for_navigation def UploadFile(): """App for testing dynamic routes.""" - from typing import Dict, List + from typing import Dict import reflex as rx @@ -27,17 +27,17 @@ def UploadFile(): class UploadState(rx.State): _file_data: Dict[str, str] = {} - event_order: rx.Field[List[str]] = rx.field([]) - progress_dicts: List[dict] = [] + event_order: rx.Field[list[str]] = rx.field([]) + progress_dicts: list[dict] = [] disabled: bool = False large_data: str = "" - async def handle_upload(self, files: List[rx.UploadFile]): + async def handle_upload(self, files: list[rx.UploadFile]): for file in files: upload_data = await file.read() self._file_data[file.filename or ""] = upload_data.decode("utf-8") - async def handle_upload_secondary(self, files: List[rx.UploadFile]): + async def handle_upload_secondary(self, files: list[rx.UploadFile]): for file in files: upload_data = await file.read() self._file_data[file.filename or ""] = upload_data.decode("utf-8") @@ -55,7 +55,7 @@ def UploadFile(): self.event_order.append("chain_event") @rx.event - async def handle_upload_tertiary(self, files: List[rx.UploadFile]): + async def handle_upload_tertiary(self, files: list[rx.UploadFile]): for file in files: (rx.get_upload_dir() / (file.filename or "INVALID")).write_bytes( await file.read() diff --git a/tests/units/compiler/test_compiler.py b/tests/units/compiler/test_compiler.py index 50088e728..cf1903c1b 100644 --- a/tests/units/compiler/test_compiler.py +++ b/tests/units/compiler/test_compiler.py @@ -1,5 +1,4 @@ from pathlib import Path -from typing import List import pytest @@ -32,7 +31,7 @@ from reflex.utils.imports import ImportVar, ParsedImportDict ], ) def test_compile_import_statement( - fields: List[ImportVar], test_default: str, test_rest: str + fields: list[ImportVar], test_default: str, test_rest: str ): """Test the compile_import_statement function. diff --git a/tests/units/components/core/test_foreach.py b/tests/units/components/core/test_foreach.py index 48fae85e8..f0d66c764 100644 --- a/tests/units/components/core/test_foreach.py +++ b/tests/units/components/core/test_foreach.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Set, Tuple, Union +from typing import Dict, Set, Tuple, Union import pydantic.v1 import pytest @@ -29,21 +29,21 @@ class ForEachTag(Base): class ForEachState(BaseState): """A state for testing the ForEach component.""" - colors_list: List[str] = ["red", "yellow"] - nested_colors_list: List[List[str]] = [["red", "yellow"], ["blue", "green"]] - colors_dict_list: List[Dict[str, str]] = [ + colors_list: list[str] = ["red", "yellow"] + nested_colors_list: list[list[str]] = [["red", "yellow"], ["blue", "green"]] + colors_dict_list: list[Dict[str, str]] = [ { "name": "red", }, {"name": "yellow"}, ] - colors_nested_dict_list: List[Dict[str, List[str]]] = [{"shades": ["light-red"]}] + colors_nested_dict_list: list[Dict[str, list[str]]] = [{"shades": ["light-red"]}] primary_color: Dict[str, str] = {"category": "primary", "name": "red"} - color_with_shades: Dict[str, List[str]] = { + color_with_shades: Dict[str, list[str]] = { "red": ["orange", "yellow"], "yellow": ["orange", "green"], } - nested_colors_with_shades: Dict[str, Dict[str, List[Dict[str, str]]]] = { + nested_colors_with_shades: Dict[str, Dict[str, list[Dict[str, str]]]] = { "primary": {"red": [{"shade": "dark"}]} } color_tuple: Tuple[str, str] = ( @@ -87,7 +87,7 @@ def display_color_name(color): def display_shade(color): - assert color._var_type == Dict[str, List[str]] + assert color._var_type == Dict[str, list[str]] return box(text(color["shades"][0])) @@ -97,12 +97,12 @@ def display_primary_colors(color): def display_color_with_shades(color): - assert color._var_type == Tuple[str, List[str]] + assert color._var_type == Tuple[str, list[str]] return box(text(color[0]), text(color[1][0])) def display_nested_color_with_shades(color): - assert color._var_type == Tuple[str, Dict[str, List[Dict[str, str]]]] + assert color._var_type == Tuple[str, Dict[str, list[Dict[str, str]]]] return box(text(color[0]), text(color[1]["red"][0]["shade"])) @@ -111,7 +111,7 @@ def show_shade(item): def display_nested_color_with_shades_v2(color): - assert color._var_type == Tuple[str, Dict[str, List[Dict[str, str]]]] + assert color._var_type == Tuple[str, Dict[str, list[Dict[str, str]]]] return box(text(foreach(color[1], show_shade))) @@ -125,8 +125,8 @@ def display_colors_set(color): return box(text(color)) -def display_nested_list_element(element: ArrayVar[List[str]], index: NumberVar[int]): - assert element._var_type == List[str] +def display_nested_list_element(element: ArrayVar[list[str]], index: NumberVar[int]): + assert element._var_type == list[str] assert index._var_type is int return box(text(element[index])) diff --git a/tests/units/components/core/test_match.py b/tests/units/components/core/test_match.py index 11602b77a..252dadbe7 100644 --- a/tests/units/components/core/test_match.py +++ b/tests/units/components/core/test_match.py @@ -1,4 +1,4 @@ -from typing import List, Mapping, Tuple +from typing import Mapping, Tuple import pytest @@ -58,7 +58,7 @@ def test_match_components(): assert second_return_value_render["children"][0]["contents"] == '{"second value"}' assert match_cases[2][0]._js_expr == "[1, 2]" - assert match_cases[2][0]._var_type == List[int] + assert match_cases[2][0]._var_type == list[int] third_return_value_render = match_cases[2][1] assert third_return_value_render["name"] == "RadixThemesText" assert third_return_value_render["children"][0]["contents"] == '{"third value"}' diff --git a/tests/units/components/test_component.py b/tests/units/components/test_component.py index 8cffa6e0e..064134314 100644 --- a/tests/units/components/test_component.py +++ b/tests/units/components/test_component.py @@ -1,5 +1,5 @@ from contextlib import nullcontext -from typing import Any, Dict, List, Optional, Type, Union +from typing import Any, Dict, Optional, Type, Union import pytest @@ -105,7 +105,7 @@ def component2() -> Type[Component]: class TestComponent2(Component): # A test list prop. - arr: Var[List[str]] + arr: Var[list[str]] on_prop_event: EventHandler[on_prop_event_spec] @@ -120,7 +120,7 @@ def component2() -> Type[Component]: "on_open": passthrough_event_spec(bool), "on_close": passthrough_event_spec(bool), "on_user_visited_count_changed": passthrough_event_spec(int), - "on_user_list_changed": passthrough_event_spec(List[str]), + "on_user_list_changed": passthrough_event_spec(list[str]), } def _get_imports(self) -> ParsedImportDict: @@ -173,11 +173,11 @@ def component5() -> Type[Component]: class TestComponent5(Component): tag = "RandomComponent" - _invalid_children: List[str] = ["Text"] + _invalid_children: list[str] = ["Text"] - _valid_children: List[str] = ["Text"] + _valid_children: list[str] = ["Text"] - _valid_parents: List[str] = ["Text"] + _valid_parents: list[str] = ["Text"] return TestComponent5 @@ -193,7 +193,7 @@ def component6() -> Type[Component]: class TestComponent6(Component): tag = "RandomComponent" - _invalid_children: List[str] = ["Text"] + _invalid_children: list[str] = ["Text"] return TestComponent6 @@ -209,7 +209,7 @@ def component7() -> Type[Component]: class TestComponent7(Component): tag = "RandomComponent" - _valid_children: List[str] = ["Text"] + _valid_children: list[str] = ["Text"] return TestComponent7 @@ -1247,9 +1247,9 @@ class ComponentNestedVar(Component): """A component with nested Var types.""" dict_of_dict: Var[Dict[str, Dict[str, str]]] - list_of_list: Var[List[List[str]]] - list_of_list_of_list: Var[List[List[List[str]]]] - list_of_dict: Var[List[Dict[str, str]]] + list_of_list: Var[list[list[str]]] + list_of_list_of_list: Var[list[list[list[str]]]] + list_of_dict: Var[list[Dict[str, str]]] class EventState(rx.State): @@ -1885,13 +1885,13 @@ def test_component_add_imports(tags): class TestBase(Component): def add_imports( # pyright: ignore [reportIncompatibleMethodOverride] self, - ) -> Dict[str, Union[str, ImportVar, List[str], List[ImportVar]]]: + ) -> Dict[str, Union[str, ImportVar, list[str], list[ImportVar]]]: return {"foo": "bar"} class Test(TestBase): def add_imports( self, - ) -> Dict[str, Union[str, ImportVar, List[str], List[ImportVar]]]: + ) -> Dict[str, Union[str, ImportVar, list[str], list[ImportVar]]]: return {"react": (tags[0] if len(tags) == 1 else tags)} baseline = Reference.create() diff --git a/tests/units/states/mutation.py b/tests/units/states/mutation.py index ad658bbd0..f5e8d1c68 100644 --- a/tests/units/states/mutation.py +++ b/tests/units/states/mutation.py @@ -143,7 +143,7 @@ class CustomVar(rx.Base): """A Base model with multiple fields.""" foo: str = "" - array: List[str] = [] + array: list[str] = [] hashmap: Dict[str, str] = {} test_set: Set[str] = set() custom: OtherBase = OtherBase() @@ -161,7 +161,7 @@ class MutableSQLAModel(MutableSQLABase): __tablename__: str = "mutable_test_state" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) - strlist: Mapped[List[str]] = mapped_column(ARRAY(String)) + strlist: Mapped[list[str]] = mapped_column(ARRAY(String)) hashmap: Mapped[Dict[str, str]] = mapped_column(JSON) test_set: Mapped[Set[str]] = mapped_column(ARRAY(String)) @@ -169,7 +169,7 @@ class MutableSQLAModel(MutableSQLABase): @serializer def serialize_mutable_sqla_model( model: MutableSQLAModel, -) -> Dict[str, Union[List[str], Dict[str, str]]]: +) -> Dict[str, Union[list[str], Dict[str, str]]]: """Serialize the MutableSQLAModel. Args: @@ -184,7 +184,7 @@ def serialize_mutable_sqla_model( class MutableTestState(BaseState): """A test state.""" - array: List[Union[str, int, List, Dict[str, str]]] = [ + array: list[Union[str, int, List, Dict[str, str]]] = [ "value", [1, 2, 3], {"key": "value"}, diff --git a/tests/units/states/upload.py b/tests/units/states/upload.py index 66d9479b4..23aa3b0a7 100644 --- a/tests/units/states/upload.py +++ b/tests/units/states/upload.py @@ -1,7 +1,7 @@ """Test states for upload-related tests.""" from pathlib import Path -from typing import ClassVar, List +from typing import ClassVar import reflex as rx from reflex.state import BaseState, State @@ -10,7 +10,7 @@ from reflex.state import BaseState, State class UploadState(BaseState): """The base state for uploading a file.""" - async def handle_upload1(self, files: List[rx.UploadFile]): + async def handle_upload1(self, files: list[rx.UploadFile]): """Handle the upload of a file. Args: @@ -30,7 +30,7 @@ class SubUploadState(BaseState): img: str - async def handle_upload(self, files: List[rx.UploadFile]): + async def handle_upload(self, files: list[rx.UploadFile]): """Handle the upload of a file. Args: @@ -42,7 +42,7 @@ class SubUploadState(BaseState): class FileUploadState(State): """The base state for uploading a file.""" - img_list: List[str] + img_list: list[str] _tmp_path: ClassVar[Path] async def handle_upload2(self, files): @@ -53,7 +53,7 @@ class FileUploadState(State): """ pass - async def multi_handle_upload(self, files: List[rx.UploadFile]): + async def multi_handle_upload(self, files: list[rx.UploadFile]): """Handle the upload of a file. Args: @@ -71,7 +71,7 @@ class FileUploadState(State): self.img_list.append(file.filename) @rx.event(background=True) - async def bg_upload(self, files: List[rx.UploadFile]): + async def bg_upload(self, files: list[rx.UploadFile]): """Background task cannot be upload handler. Args: @@ -89,7 +89,7 @@ class FileStateBase1(State): class ChildFileUploadState(FileStateBase1): """The child state for uploading a file.""" - img_list: List[str] + img_list: list[str] _tmp_path: ClassVar[Path] async def handle_upload2(self, files): @@ -100,7 +100,7 @@ class ChildFileUploadState(FileStateBase1): """ pass - async def multi_handle_upload(self, files: List[rx.UploadFile]): + async def multi_handle_upload(self, files: list[rx.UploadFile]): """Handle the upload of a file. Args: @@ -118,7 +118,7 @@ class ChildFileUploadState(FileStateBase1): self.img_list.append(file.filename) @rx.event(background=True) - async def bg_upload(self, files: List[rx.UploadFile]): + async def bg_upload(self, files: list[rx.UploadFile]): """Background task cannot be upload handler. Args: @@ -136,7 +136,7 @@ class FileStateBase2(FileStateBase1): class GrandChildFileUploadState(FileStateBase2): """The child state for uploading a file.""" - img_list: List[str] + img_list: list[str] _tmp_path: ClassVar[Path] async def handle_upload2(self, files): @@ -147,7 +147,7 @@ class GrandChildFileUploadState(FileStateBase2): """ pass - async def multi_handle_upload(self, files: List[rx.UploadFile]): + async def multi_handle_upload(self, files: list[rx.UploadFile]): """Handle the upload of a file. Args: @@ -165,7 +165,7 @@ class GrandChildFileUploadState(FileStateBase2): self.img_list.append(file.filename) @rx.event(background=True) - async def bg_upload(self, files: List[rx.UploadFile]): + async def bg_upload(self, files: list[rx.UploadFile]): """Background task cannot be upload handler. Args: diff --git a/tests/units/test_app.py b/tests/units/test_app.py index 88cb36509..74381070a 100644 --- a/tests/units/test_app.py +++ b/tests/units/test_app.py @@ -9,7 +9,7 @@ import unittest.mock import uuid from contextlib import nullcontext as does_not_raise from pathlib import Path -from typing import Generator, List, Tuple, Type +from typing import Generator, Tuple, Type from unittest.mock import AsyncMock import pytest @@ -570,7 +570,7 @@ async def test_dynamic_var_event(test_state: Type[ATestState], token: str): ], ) async def test_list_mutation_detection__plain_list( - event_tuples: List[Tuple[str, List[str]]], + event_tuples: list[Tuple[str, list[str]]], list_mutation_state: State, token: str, ): @@ -695,7 +695,7 @@ async def test_list_mutation_detection__plain_list( ], ) async def test_dict_mutation_detection__plain_list( - event_tuples: List[Tuple[str, List[str]]], + event_tuples: list[Tuple[str, list[str]]], dict_mutation_state: State, token: str, ): @@ -817,7 +817,7 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker): [FileUploadState, ChildFileUploadState, GrandChildFileUploadState], ) async def test_upload_file_without_annotation(state, tmp_path, token): - """Test that an error is thrown when there's no param annotated with rx.UploadFile or List[UploadFile]. + """Test that an error is thrown when there's no param annotated with rx.UploadFile or list[UploadFile]. Args: state: The state class. @@ -838,7 +838,7 @@ async def test_upload_file_without_annotation(state, tmp_path, token): await fn(request_mock, [file_mock]) assert ( err.value.args[0] - == f"`{state.get_full_name()}.handle_upload2` handler should have a parameter annotated as List[rx.UploadFile]" + == f"`{state.get_full_name()}.handle_upload2` handler should have a parameter annotated as list[rx.UploadFile]" ) if isinstance(app.state_manager, StateManagerRedis): @@ -1523,22 +1523,22 @@ def test_app_with_transpile_packages(compilable_app: tuple[App, Path], export: b class C1(rx.Component): library = "foo@1.2.3" tag = "Foo" - transpile_packages: List[str] = ["foo"] + transpile_packages: list[str] = ["foo"] class C2(rx.Component): library = "bar@4.5.6" tag = "Bar" - transpile_packages: List[str] = ["bar@4.5.6"] + transpile_packages: list[str] = ["bar@4.5.6"] class C3(rx.NoSSRComponent): library = "baz@7.8.10" tag = "Baz" - transpile_packages: List[str] = ["baz@7.8.9"] + transpile_packages: list[str] = ["baz@7.8.9"] class C4(rx.NoSSRComponent): library = "quuc@2.3.4" tag = "Quuc" - transpile_packages: List[str] = ["quuc"] + transpile_packages: list[str] = ["quuc"] class C5(rx.Component): library = "quuc" diff --git a/tests/units/test_attribute_access_type.py b/tests/units/test_attribute_access_type.py index d08c17c8c..ebacaec9a 100644 --- a/tests/units/test_attribute_access_type.py +++ b/tests/units/test_attribute_access_type.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Optional, Type, Union +from typing import Dict, Optional, Type, Union import attrs import pydantic.v1 @@ -74,16 +74,16 @@ class SQLAClass(SQLABase): id: Mapped[int] = mapped_column(primary_key=True) count: Mapped[int] = mapped_column() name: Mapped[str] = mapped_column() - int_list: Mapped[List[int]] = mapped_column( + int_list: Mapped[list[int]] = mapped_column( sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER) ) - str_list: Mapped[List[str]] = mapped_column( + str_list: Mapped[list[str]] = mapped_column( sqlalchemy.types.ARRAY(item_type=sqlalchemy.String) ) optional_int: Mapped[Optional[int]] = mapped_column(nullable=True) sqla_tag_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey(SQLATag.id)) sqla_tag: Mapped[Optional[SQLATag]] = relationship() - labels: Mapped[List[SQLALabel]] = relationship(back_populates="test") + labels: Mapped[list[SQLALabel]] = relationship(back_populates="test") # do not use lower case dict here! # https://github.com/sqlalchemy/sqlalchemy/issues/9902 dict_str_str: Mapped[Dict[str, str]] = mapped_column() @@ -123,20 +123,20 @@ class SQLAClassDataclass(MappedAsDataclass, SQLABase): no_default: Mapped[int] = mapped_column(nullable=True) count: Mapped[int] = mapped_column() name: Mapped[str] = mapped_column() - int_list: Mapped[List[int]] = mapped_column( + int_list: Mapped[list[int]] = mapped_column( sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER) ) - str_list: Mapped[List[str]] = mapped_column( + str_list: Mapped[list[str]] = mapped_column( sqlalchemy.types.ARRAY(item_type=sqlalchemy.String) ) optional_int: Mapped[Optional[int]] = mapped_column(nullable=True) sqla_tag_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey(SQLATag.id)) sqla_tag: Mapped[Optional[SQLATag]] = relationship() - labels: Mapped[List[SQLALabel]] = relationship(back_populates="test_dataclass") + labels: Mapped[list[SQLALabel]] = relationship(back_populates="test_dataclass") # do not use lower case dict here! # https://github.com/sqlalchemy/sqlalchemy/issues/9902 dict_str_str: Mapped[Dict[str, str]] = mapped_column() - default_factory: Mapped[List[int]] = mapped_column( + default_factory: Mapped[list[int]] = mapped_column( sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER), default_factory=list, ) @@ -176,13 +176,13 @@ class ModelClass(rx.Model): no_default: Optional[int] = sqlmodel.Field(nullable=True) count: int = 0 name: str = "test" - int_list: List[int] = [] - str_list: List[str] = [] + int_list: list[int] = [] + str_list: list[str] = [] optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None - labels: List[SQLALabel] = [] + labels: list[SQLALabel] = [] dict_str_str: Dict[str, str] = {} - default_factory: List[int] = sqlmodel.Field(default_factory=list) + default_factory: list[int] = sqlmodel.Field(default_factory=list) @property def str_property(self) -> str: @@ -218,13 +218,13 @@ class BaseClass(rx.Base): no_default: Optional[int] = pydantic.v1.Field(required=False) count: int = 0 name: str = "test" - int_list: List[int] = [] - str_list: List[str] = [] + int_list: list[int] = [] + str_list: list[str] = [] optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None - labels: List[SQLALabel] = [] + labels: list[SQLALabel] = [] dict_str_str: Dict[str, str] = {} - default_factory: List[int] = pydantic.v1.Field(default_factory=list) + default_factory: list[int] = pydantic.v1.Field(default_factory=list) @property def str_property(self) -> str: @@ -259,11 +259,11 @@ class BareClass: count: int = 0 name: str = "test" - int_list: List[int] = [] - str_list: List[str] = [] + int_list: list[int] = [] + str_list: list[str] = [] optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None - labels: List[SQLALabel] = [] + labels: list[SQLALabel] = [] dict_str_str: Dict[str, str] = {} @property @@ -300,13 +300,13 @@ class AttrClass: count: int = 0 name: str = "test" - int_list: List[int] = [] - str_list: List[str] = [] + int_list: list[int] = [] + str_list: list[str] = [] optional_int: Optional[int] = None sqla_tag: Optional[SQLATag] = None - labels: List[SQLALabel] = [] + labels: list[SQLALabel] = [] dict_str_str: Dict[str, str] = {} - default_factory: List[int] = attrs.field(factory=list) + default_factory: list[int] = attrs.field(factory=list) @property def str_property(self) -> str: @@ -352,11 +352,11 @@ class AttrClass: [ pytest.param("count", int, id="int"), pytest.param("name", str, id="str"), - pytest.param("int_list", List[int], id="List[int]"), - pytest.param("str_list", List[str], id="List[str]"), + pytest.param("int_list", list[int], id="list[int]"), + pytest.param("str_list", list[str], id="list[str]"), pytest.param("optional_int", Optional[int], id="Optional[int]"), pytest.param("sqla_tag", Optional[SQLATag], id="Optional[SQLATag]"), - pytest.param("labels", List[SQLALabel], id="List[SQLALabel]"), + pytest.param("labels", list[SQLALabel], id="list[SQLALabel]"), pytest.param("dict_str_str", Dict[str, str], id="Dict[str, str]"), pytest.param("str_property", str, id="str_property"), pytest.param("str_or_int_property", Union[str, int], id="str_or_int_property"), @@ -389,7 +389,7 @@ def test_get_attribute_access_type_default_factory(cls: type) -> None: Args: cls: Class to test. """ - assert get_attribute_access_type(cls, "default_factory") == List[int] + assert get_attribute_access_type(cls, "default_factory") == list[int] @pytest.mark.parametrize( diff --git a/tests/units/test_event.py b/tests/units/test_event.py index df4f282cf..e8320d0dd 100644 --- a/tests/units/test_event.py +++ b/tests/units/test_event.py @@ -1,4 +1,4 @@ -from typing import Callable, List +from typing import Callable import pytest @@ -106,7 +106,7 @@ def test_call_event_handler_partial(): test_fn_with_args.__qualname__ = "test_fn_with_args" - def spec(a2: Var[str]) -> List[Var[str]]: + def spec(a2: Var[str]) -> list[Var[str]]: return [a2] handler = EventHandler(fn=test_fn_with_args, state_full_name="BigState") diff --git a/tests/units/test_state.py b/tests/units/test_state.py index e0390c5ac..1deeb2f24 100644 --- a/tests/units/test_state.py +++ b/tests/units/test_state.py @@ -16,7 +16,6 @@ from typing import ( Callable, ClassVar, Dict, - List, Optional, Set, Tuple, @@ -121,8 +120,8 @@ class TestState(BaseState): num2: float = 3.14 key: str map_key: str = "a" - array: List[float] = [1, 2, 3.14] - mapping: Dict[str, List[int]] = {"a": [1, 2, 3], "b": [4, 5, 6]} + array: list[float] = [1, 2, 3.14] + mapping: Dict[str, list[int]] = {"a": [1, 2, 3], "b": [4, 5, 6]} obj: Object = Object() complex: Dict[int, Object] = {1: Object(), 2: Object()} fig: Figure = Figure() @@ -952,7 +951,7 @@ def test_add_var(): # New instances get an actual value with the default assert DynamicState().dynamic_int == 42 - ds1.add_var("dynamic_list", List[int], [5, 10]) + ds1.add_var("dynamic_list", list[int], [5, 10]) assert ds1.dynamic_list.equals(DynamicState.dynamic_list) # pyright: ignore [reportAttributeAccessIssue] ds2 = DynamicState() assert ds2.dynamic_list == [5, 10] @@ -1393,8 +1392,8 @@ def test_computed_var_dependencies(): v: int = 0 w: int = 0 x: int = 0 - y: List[int] = [1, 2, 3] - _z: List[int] = [1, 2, 3] + y: list[int] = [1, 2, 3] + _z: list[int] = [1, 2, 3] @property def testprop(self) -> int: @@ -1459,7 +1458,7 @@ def test_computed_var_dependencies(): return [round(y) for y in self.y] @rx.var - def comp_z(self) -> List[bool]: + def comp_z(self) -> list[bool]: """Comprehension accesses attribute. Returns: @@ -2048,8 +2047,8 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): class BackgroundTaskState(BaseState): """A state with a background task.""" - order: List[str] = [] - dict_list: Dict[str, List[int]] = {"foo": [1, 2, 3]} + order: list[str] = [] + dict_list: Dict[str, list[int]] = {"foo": [1, 2, 3]} dc: ModelDC = ModelDC() def __init__(self, **kwargs): # noqa: D107 @@ -2057,7 +2056,7 @@ class BackgroundTaskState(BaseState): self.router_data = {"simulate": "hydrate"} @rx.var(cache=False) - def computed_order(self) -> List[str]: + def computed_order(self) -> list[str]: """Get the order as a computed var. Returns: @@ -2642,14 +2641,14 @@ def test_duplicate_substate_class(mocker): class Foo(Base): """A class containing a list of str.""" - tags: List[str] = ["123", "456"] + tags: list[str] = ["123", "456"] def test_json_dumps_with_mutables(): """Test that json.dumps works with Base vars inside mutable types.""" class MutableContainsBase(BaseState): - items: List[Foo] = [Foo()] + items: list[Foo] = [Foo()] dict_val = MutableContainsBase().dict() assert isinstance(dict_val[MutableContainsBase.get_full_name()]["items"][0], Foo) @@ -2668,7 +2667,7 @@ def test_reset_with_mutables(): copied_default = copy.deepcopy(default) class MutableResetState(BaseState): - items: List[List[int]] = default + items: list[list[int]] = default instance = MutableResetState() assert instance.items.__wrapped__ is not default # pyright: ignore [reportAttributeAccessIssue] @@ -3890,7 +3889,7 @@ class Table(rx.ComponentState): data: ClassVar[Var] @rx.var(cache=True, auto_deps=False) - async def rows(self) -> List[Dict[str, Any]]: + async def rows(self) -> list[Dict[str, Any]]: """Computed var over the given rows. Returns: @@ -3925,7 +3924,7 @@ async def test_async_computed_var_get_var_value(mock_app: rx.App, token: str): class OtherState(rx.State): """A state with a var.""" - data: List[Dict[str, Any]] = [{"foo": "bar"}] + data: list[Dict[str, Any]] = [{"foo": "bar"}] mock_app.state_manager.state = mock_app._state = rx.State comp = Table.create(data=OtherState.data) diff --git a/tests/units/test_var.py b/tests/units/test_var.py index 8fcd288e6..75423151d 100644 --- a/tests/units/test_var.py +++ b/tests/units/test_var.py @@ -273,7 +273,7 @@ def test_get_setter(prop: Var, expected): (1, Var(_js_expr="1", _var_type=int)), ("key", Var(_js_expr='"key"', _var_type=str)), (3.14, Var(_js_expr="3.14", _var_type=float)), - ([1, 2, 3], Var(_js_expr="[1, 2, 3]", _var_type=List[int])), + ([1, 2, 3], Var(_js_expr="[1, 2, 3]", _var_type=list[int])), ( {"a": 1, "b": 2}, Var(_js_expr='({ ["a"] : 1, ["b"] : 2 })', _var_type=Mapping[str, int]), @@ -482,7 +482,7 @@ def test_dict_contains(var, expected): @pytest.mark.parametrize( "var", [ - Var(_js_expr="list", _var_type=List[int]).guess_type(), + Var(_js_expr="list", _var_type=list[int]).guess_type(), Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), Var(_js_expr="str", _var_type=str).guess_type(), ], @@ -504,7 +504,7 @@ def test_var_indexing_lists(var): @pytest.mark.parametrize( "var, type_", [ - (Var(_js_expr="list", _var_type=List[int]).guess_type(), [int, int]), + (Var(_js_expr="list", _var_type=list[int]).guess_type(), [int, int]), ( Var(_js_expr="tuple", _var_type=Tuple[int, str]).guess_type(), [int, str], @@ -565,39 +565,39 @@ def test_computed_var_replace_with_invalid_kwargs(): @pytest.mark.parametrize( "var, index", [ - (Var(_js_expr="lst", _var_type=List[int]).guess_type(), [1, 2]), + (Var(_js_expr="lst", _var_type=list[int]).guess_type(), [1, 2]), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), {"name": "dict"}, ), - (Var(_js_expr="lst", _var_type=List[int]).guess_type(), {"set"}), + (Var(_js_expr="lst", _var_type=list[int]).guess_type(), {"set"}), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), ( 1, 2, ), ), - (Var(_js_expr="lst", _var_type=List[int]).guess_type(), 1.5), - (Var(_js_expr="lst", _var_type=List[int]).guess_type(), "str"), + (Var(_js_expr="lst", _var_type=list[int]).guess_type(), 1.5), + (Var(_js_expr="lst", _var_type=list[int]).guess_type(), "str"), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), Var(_js_expr="float_var", _var_type=float).guess_type(), ), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), - Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), + Var(_js_expr="list_var", _var_type=list[int]).guess_type(), ), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), (Var(_js_expr="str", _var_type=str).guess_type(), [1, 2]), @@ -641,7 +641,7 @@ def test_var_unsupported_indexing_lists(var, index): @pytest.mark.parametrize( "var", [ - Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="lst", _var_type=list[int]).guess_type(), Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), ], ) @@ -710,7 +710,7 @@ def test_dict_indexing(): ), ( Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), - Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + Var(_js_expr="list_var", _var_type=list[int]).guess_type(), ), ( Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), @@ -741,7 +741,7 @@ def test_dict_indexing(): ), ( Var(_js_expr="df", _var_type=DataFrame).guess_type(), - Var(_js_expr="list_var", _var_type=List[int]).guess_type(), + Var(_js_expr="list_var", _var_type=list[int]).guess_type(), ), ( Var(_js_expr="df", _var_type=DataFrame).guess_type(), @@ -1135,8 +1135,8 @@ def test_type_chains(): object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3}) assert (object_var._key_type(), object_var._value_type()) == (str, int) assert (object_var.keys()._var_type, object_var.values()._var_type) == ( - List[str], - List[int], + list[str], + list[int], ) assert ( str(object_var.keys()[0].upper()) @@ -1153,7 +1153,7 @@ def test_type_chains(): def test_nested_dict(): - arr = LiteralArrayVar.create([{"bar": ["foo", "bar"]}], List[Dict[str, List[str]]]) + arr = LiteralArrayVar.create([{"bar": ["foo", "bar"]}], list[Dict[str, list[str]]]) assert ( str(arr[0]["bar"][0]) == '[({ ["bar"] : ["foo", "bar"] })].at(0)["bar"].at(0)' # pyright: ignore [reportIndexIssue] @@ -1474,7 +1474,7 @@ def test_unsupported_default_contains(): ), ], ) -def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): +def test_valid_var_operations(operand1_var: Var, operand2_var, operators: list[str]): """Test that operations do not raise a TypeError. Args: @@ -1766,7 +1766,7 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s ), ], ) -def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): +def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: list[str]): for operator in operators: print(f"testing {operator} on {operand1_var!s} and {operand2_var!s}") with pytest.raises(TypeError): @@ -1813,7 +1813,7 @@ def cv_fget(state: BaseState) -> int: ([ComputedVar(fget=cv_fget)], {None: {"cv_fget"}}), ], ) -def test_computed_var_deps(deps: List[Union[str, Var]], expected: Set[str]): +def test_computed_var_deps(deps: list[Union[str, Var]], expected: Set[str]): @computed_var(deps=deps) def test_var(state) -> int: return 1 diff --git a/tests/units/utils/test_format.py b/tests/units/utils/test_format.py index 89197a03e..f16bd137c 100644 --- a/tests/units/utils/test_format.py +++ b/tests/units/utils/test_format.py @@ -2,7 +2,7 @@ from __future__ import annotations import datetime import json -from typing import Any, List +from typing import Any import plotly.graph_objects as go import pytest @@ -334,7 +334,7 @@ def test_format_route(route: str, format_case: bool, expected: bool): ) def test_format_match( condition: str, - match_cases: List[List[Var]], + match_cases: list[list[Var]], default: Var, expected: str, ): diff --git a/tests/units/utils/test_types.py b/tests/units/utils/test_types.py index 87790e979..a4a1109e0 100644 --- a/tests/units/utils/test_types.py +++ b/tests/units/utils/test_types.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Literal, Tuple, Union +from typing import Any, Dict, Literal, Tuple, Union import pytest @@ -27,7 +27,7 @@ def test_validate_literal_error_msg(params, allowed_value_str, value_str): [ (int, Any, True), (Tuple[int], Any, True), - (List[int], Any, True), + (list[int], Any, True), (int, int, True), (int, object, True), (int, Union[int, str], True), @@ -38,7 +38,7 @@ def test_validate_literal_error_msg(params, allowed_value_str, value_str): (int, Union[str, float], False), (int, Union[float, str], False), (int, str, False), - (int, List[int], False), + (int, list[int], False), ], ) def test_issubclass( @@ -78,7 +78,7 @@ class ChildGenericDict(GenericDict): (str, False), (float, False), (Tuple[int], True), - (List[int], True), + (list[int], True), (Union[int, str], True), (Union[str, int], True), (Dict[str, int], True), diff --git a/tests/units/utils/test_utils.py b/tests/units/utils/test_utils.py index 74dcf79b0..c2d3ef6f5 100644 --- a/tests/units/utils/test_utils.py +++ b/tests/units/utils/test_utils.py @@ -61,7 +61,7 @@ def test_func(): (float, False), (bool, False), (List, True), - (List[int], True), + (list[int], True), ], ) def test_is_generic_alias(cls: type, expected: bool): @@ -90,16 +90,16 @@ def test_is_generic_alias(cls: type, expected: bool): (bool, int, True), (int, bool, False), (list, List, True), - (list, List[str], True), # this is wrong, but it's a limitation of the function + (list, list[str], True), # this is wrong, but it's a limitation of the function (List, list, True), - (List[int], list, True), - (List[int], List, True), - (List[int], List[str], False), - (List[int], List[int], True), - (List[int], List[float], False), - (List[int], List[Union[int, float]], True), - (List[int], List[Union[float, str]], False), - (Union[int, float], List[Union[int, float]], False), + (list[int], list, True), + (list[int], List, True), + (list[int], list[str], False), + (list[int], list[int], True), + (list[int], list[float], False), + (list[int], list[Union[int, float]], True), + (list[int], list[Union[float, str]], False), + (Union[int, float], list[Union[int, float]], False), (Union[int, float], Union[int, float, str], True), (Union[int, float], Union[str, float], False), (Dict[str, int], Dict[str, int], True), @@ -252,8 +252,8 @@ def test_is_backend_base_variable( (int, Union[int, float], True), (float, Union[int, float], True), (str, Union[int, float], False), - (List[int], List[int], True), - (List[int], List[float], True), + (list[int], list[int], True), + (list[int], list[float], True), (Union[int, float], Union[int, float], False), (Union[int, Var[int]], Var[int], False), (int, Any, True), diff --git a/tests/units/vars/test_base.py b/tests/units/vars/test_base.py index 8f9e99fe4..595353aeb 100644 --- a/tests/units/vars/test_base.py +++ b/tests/units/vars/test_base.py @@ -1,4 +1,4 @@ -from typing import List, Mapping, Union +from typing import Mapping, Union import pytest @@ -36,8 +36,8 @@ class ChildGenericDict(GenericDict): (1, int), (1.0, float), ("a", str), - ([1, 2, 3], List[int]), - ([1, 2.0, "a"], List[Union[int, float, str]]), + ([1, 2, 3], list[int]), + ([1, 2.0, "a"], list[Union[int, float, str]]), ({"a": 1, "b": 2}, Mapping[str, int]), ({"a": 1, 2: "b"}, Mapping[Union[int, str], Union[str, int]]), (CustomDict(), CustomDict),