do the same for tuple
This commit is contained in:
parent
2430a9c1e2
commit
d0940b9cef
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Iterable, Optional, Sequence, Tuple, Type, Union
|
from typing import TYPE_CHECKING, Iterable, Optional, Sequence, Type, Union
|
||||||
|
|
||||||
from reflex import constants
|
from reflex import constants
|
||||||
from reflex.compiler import templates, utils
|
from reflex.compiler import templates, utils
|
||||||
@ -594,7 +594,7 @@ def compile_unevaluated_page(
|
|||||||
state: Type[BaseState] | None = None,
|
state: Type[BaseState] | None = None,
|
||||||
style: ComponentStyle | None = None,
|
style: ComponentStyle | None = None,
|
||||||
theme: Component | None = None,
|
theme: Component | None = None,
|
||||||
) -> Tuple[Component, bool]:
|
) -> tuple[Component, bool]:
|
||||||
"""Compiles an uncompiled page into a component and adds meta information.
|
"""Compiles an uncompiled page into a component and adds meta information.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Tuple
|
|
||||||
|
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
from reflex.components.datadisplay.logo import svg_logo
|
from reflex.components.datadisplay.logo import svg_logo
|
||||||
from reflex.components.el import a, button, details, div, h2, hr, p, pre, summary
|
from reflex.components.el import a, button, details, div, h2, hr, p, pre, summary
|
||||||
@ -16,7 +14,7 @@ from reflex.vars.object import ObjectVar
|
|||||||
|
|
||||||
def on_error_spec(
|
def on_error_spec(
|
||||||
error: ObjectVar[dict[str, str]], info: ObjectVar[dict[str, str]]
|
error: ObjectVar[dict[str, str]], info: ObjectVar[dict[str, str]]
|
||||||
) -> Tuple[Var[str], Var[str]]:
|
) -> tuple[Var[str], Var[str]]:
|
||||||
"""The spec for the on_error event handler.
|
"""The spec for the on_error event handler.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# ------------------- DO NOT EDIT ----------------------
|
# ------------------- DO NOT EDIT ----------------------
|
||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from typing import Any, Optional, Tuple, Union, overload
|
from typing import Any, Optional, Union, overload
|
||||||
|
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
from reflex.event import EventType
|
from reflex.event import EventType
|
||||||
@ -13,7 +13,7 @@ from reflex.vars.object import ObjectVar
|
|||||||
|
|
||||||
def on_error_spec(
|
def on_error_spec(
|
||||||
error: ObjectVar[dict[str, str]], info: ObjectVar[dict[str, str]]
|
error: ObjectVar[dict[str, str]], info: ObjectVar[dict[str, str]]
|
||||||
) -> Tuple[Var[str], Var[str]]: ...
|
) -> tuple[Var[str], Var[str]]: ...
|
||||||
|
|
||||||
class ErrorBoundary(Component):
|
class ErrorBoundary(Component):
|
||||||
@overload
|
@overload
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Tuple, TypeVar, Union
|
from typing import TypeVar, Union
|
||||||
|
|
||||||
breakpoints_values = ["30em", "48em", "62em", "80em", "96em"]
|
breakpoints_values = ["30em", "48em", "62em", "80em", "96em"]
|
||||||
breakpoint_names = ["xs", "sm", "md", "lg", "xl"]
|
breakpoint_names = ["xs", "sm", "md", "lg", "xl"]
|
||||||
|
|
||||||
|
|
||||||
def set_breakpoints(values: Tuple[str, str, str, str, str]):
|
def set_breakpoints(values: tuple[str, str, str, str, str]):
|
||||||
"""Overwrite default breakpoint values.
|
"""Overwrite default breakpoint values.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Tuple, Union
|
from typing import Union
|
||||||
|
|
||||||
from reflex.components.base.fragment import Fragment
|
from reflex.components.base.fragment import Fragment
|
||||||
from reflex.components.tags.tag import Tag
|
from reflex.components.tags.tag import Tag
|
||||||
@ -21,7 +21,7 @@ class Clipboard(Fragment):
|
|||||||
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.
|
# 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.
|
# Save the original event actions for the on_paste event.
|
||||||
on_paste_event_actions: Var[dict[str, Union[bool, int]]]
|
on_paste_event_actions: Var[dict[str, Union[bool, int]]]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""rx.match."""
|
"""rx.match."""
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from reflex.components.base import Fragment
|
from reflex.components.base import Fragment
|
||||||
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
|
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
|
||||||
@ -77,7 +77,7 @@ class Match(MemoizationLeaf):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _process_cases(
|
def _process_cases(
|
||||||
cls, cases: List
|
cls, cases: List
|
||||||
) -> Tuple[List, Optional[Union[Var, BaseComponent]]]:
|
) -> tuple[List, Optional[Union[Var, BaseComponent]]]:
|
||||||
"""Process the list of match cases and the catchall default case.
|
"""Process the list of match cases and the catchall default case.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable, ClassVar, List, Optional, Tuple
|
from typing import Any, Callable, ClassVar, List, Optional
|
||||||
|
|
||||||
from reflex.components.base.fragment import Fragment
|
from reflex.components.base.fragment import Fragment
|
||||||
from reflex.components.component import (
|
from reflex.components.component import (
|
||||||
@ -161,7 +161,7 @@ def get_upload_url(file_path: str | Var[str]) -> Var[str]:
|
|||||||
return Var.create(f"{uploaded_files_url_prefix}/{file_path}")
|
return Var.create(f"{uploaded_files_url_prefix}/{file_path}")
|
||||||
|
|
||||||
|
|
||||||
def _on_drop_spec(files: Var) -> Tuple[Var[Any]]:
|
def _on_drop_spec(files: Var) -> tuple[Var[Any]]:
|
||||||
"""Args spec for the on_drop event trigger.
|
"""Args spec for the on_drop event trigger.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Dict, Literal, Optional, Tuple, TypedDict, Union
|
from typing import Any, Dict, Literal, Optional, TypedDict, Union
|
||||||
|
|
||||||
from reflex.base import Base
|
from reflex.base import Base
|
||||||
from reflex.components.component import Component, NoSSRComponent
|
from reflex.components.component import Component, NoSSRComponent
|
||||||
@ -260,20 +260,20 @@ class DataEditor(NoSSRComponent):
|
|||||||
theme: Var[Union[DataEditorTheme, Dict]]
|
theme: Var[Union[DataEditorTheme, Dict]]
|
||||||
|
|
||||||
# Fired when a cell is activated.
|
# Fired when a cell is activated.
|
||||||
on_cell_activated: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_cell_activated: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a cell is clicked.
|
# Fired when a cell is clicked.
|
||||||
on_cell_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_cell_clicked: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a cell is right-clicked.
|
# Fired when a cell is right-clicked.
|
||||||
on_cell_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_cell_context_menu: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a cell is edited.
|
# Fired when a cell is edited.
|
||||||
on_cell_edited: EventHandler[passthrough_event_spec(Tuple[int, int], GridCell)]
|
on_cell_edited: EventHandler[passthrough_event_spec(tuple[int, int], GridCell)]
|
||||||
|
|
||||||
# Fired when a group header is clicked.
|
# Fired when a group header is clicked.
|
||||||
on_group_header_clicked: EventHandler[
|
on_group_header_clicked: EventHandler[
|
||||||
passthrough_event_spec(Tuple[int, int], GridCell)
|
passthrough_event_spec(tuple[int, int], GridCell)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Fired when a group header is right-clicked.
|
# Fired when a group header is right-clicked.
|
||||||
@ -285,16 +285,16 @@ class DataEditor(NoSSRComponent):
|
|||||||
on_group_header_renamed: EventHandler[passthrough_event_spec(str, str)]
|
on_group_header_renamed: EventHandler[passthrough_event_spec(str, str)]
|
||||||
|
|
||||||
# Fired when a header is clicked.
|
# Fired when a header is clicked.
|
||||||
on_header_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_header_clicked: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a header is right-clicked.
|
# Fired when a header is right-clicked.
|
||||||
on_header_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_header_context_menu: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a header menu item is clicked.
|
# Fired when a header menu item is clicked.
|
||||||
on_header_menu_click: EventHandler[passthrough_event_spec(int, Rectangle)]
|
on_header_menu_click: EventHandler[passthrough_event_spec(int, Rectangle)]
|
||||||
|
|
||||||
# Fired when an item is hovered.
|
# Fired when an item is hovered.
|
||||||
on_item_hovered: EventHandler[passthrough_event_spec(Tuple[int, int])]
|
on_item_hovered: EventHandler[passthrough_event_spec(tuple[int, int])]
|
||||||
|
|
||||||
# Fired when a selection is deleted.
|
# Fired when a selection is deleted.
|
||||||
on_delete: EventHandler[passthrough_event_spec(GridSelection)]
|
on_delete: EventHandler[passthrough_event_spec(GridSelection)]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from typing import Any, Iterator, Literal, Tuple, Union
|
from typing import Any, Iterator, Literal, Union
|
||||||
|
|
||||||
from jinja2 import Environment
|
from jinja2 import Environment
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class Fieldset(Element):
|
|||||||
name: Var[str]
|
name: Var[str]
|
||||||
|
|
||||||
|
|
||||||
def on_submit_event_spec() -> Tuple[Var[dict[str, Any]]]:
|
def on_submit_event_spec() -> tuple[Var[dict[str, Any]]]:
|
||||||
"""Event handler spec for the on_submit event.
|
"""Event handler spec for the on_submit event.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -113,7 +113,7 @@ def on_submit_event_spec() -> Tuple[Var[dict[str, Any]]]:
|
|||||||
return (FORM_DATA,)
|
return (FORM_DATA,)
|
||||||
|
|
||||||
|
|
||||||
def on_submit_string_event_spec() -> Tuple[Var[dict[str, str]]]:
|
def on_submit_string_event_spec() -> tuple[Var[dict[str, str]]]:
|
||||||
"""Event handler spec for the on_submit event.
|
"""Event handler spec for the on_submit event.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# ------------------- DO NOT EDIT ----------------------
|
# ------------------- DO NOT EDIT ----------------------
|
||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from typing import Any, Literal, Optional, Tuple, Union, overload
|
from typing import Any, Literal, Optional, Union, overload
|
||||||
|
|
||||||
from jinja2 import Environment
|
from jinja2 import Environment
|
||||||
|
|
||||||
@ -634,8 +634,8 @@ class Fieldset(Element):
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def on_submit_event_spec() -> Tuple[Var[dict[str, Any]]]: ...
|
def on_submit_event_spec() -> tuple[Var[dict[str, Any]]]: ...
|
||||||
def on_submit_string_event_spec() -> Tuple[Var[dict[str, str]]]: ...
|
def on_submit_string_event_spec() -> tuple[Var[dict[str, str]]]: ...
|
||||||
|
|
||||||
class Form(BaseHTML):
|
class Form(BaseHTML):
|
||||||
@overload
|
@overload
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, Tuple, TypedDict, TypeVar, Union
|
from typing import Any, Dict, TypedDict, TypeVar, Union
|
||||||
|
|
||||||
from reflex.components.component import Component, NoSSRComponent
|
from reflex.components.component import Component, NoSSRComponent
|
||||||
from reflex.components.core.cond import color_mode_cond
|
from reflex.components.core.cond import color_mode_cond
|
||||||
@ -21,7 +21,7 @@ except ImportError:
|
|||||||
Template = Any
|
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.
|
"""For plotly events with event data containing a point array.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Literal, Tuple, Union
|
from typing import Any, Literal, Union
|
||||||
|
|
||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
from reflex.components.core.colors import color
|
from reflex.components.core.colors import color
|
||||||
@ -72,7 +72,7 @@ class AccordionComponent(RadixPrimitiveComponent):
|
|||||||
return ["color_scheme", "variant"]
|
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.
|
"""Handle the on_value_change event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# ------------------- DO NOT EDIT ----------------------
|
# ------------------- DO NOT EDIT ----------------------
|
||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from typing import Any, Literal, Optional, Tuple, Union, overload
|
from typing import Any, Literal, Optional, Union, overload
|
||||||
|
|
||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
from reflex.components.lucide.icon import Icon
|
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):
|
class AccordionRoot(AccordionComponent):
|
||||||
def add_style(self): ...
|
def add_style(self): ...
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Literal, Tuple
|
from typing import Any, Literal
|
||||||
|
|
||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
|
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
|
||||||
@ -21,7 +21,7 @@ class SliderComponent(RadixPrimitiveComponentWithClassName):
|
|||||||
|
|
||||||
def on_value_event_spec(
|
def on_value_event_spec(
|
||||||
value: Var[list[int]],
|
value: Var[list[int]],
|
||||||
) -> Tuple[Var[list[int]]]:
|
) -> tuple[Var[list[int]]]:
|
||||||
"""Event handler spec for the value event.
|
"""Event handler spec for the value event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# ------------------- DO NOT EDIT ----------------------
|
# ------------------- DO NOT EDIT ----------------------
|
||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from typing import Any, Literal, Optional, Tuple, Union, overload
|
from typing import Any, Literal, Optional, Union, overload
|
||||||
|
|
||||||
from reflex.components.component import Component, ComponentNamespace
|
from reflex.components.component import Component, ComponentNamespace
|
||||||
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
|
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):
|
class SliderRoot(SliderComponent):
|
||||||
def add_style(self) -> dict[str, Any] | None: ...
|
def add_style(self) -> dict[str, Any] | None: ...
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Literal, Tuple, Union
|
from typing import Literal, Union
|
||||||
|
|
||||||
from reflex.components.core.breakpoints import Responsive
|
from reflex.components.core.breakpoints import Responsive
|
||||||
from reflex.event import EventHandler
|
from reflex.event import EventHandler
|
||||||
@ -14,7 +14,7 @@ from ..base import LiteralAccentColor, RadixThemesComponent
|
|||||||
|
|
||||||
def on_value_change(
|
def on_value_change(
|
||||||
value: Var[Union[str, list[str]]],
|
value: Var[Union[str, list[str]]],
|
||||||
) -> Tuple[Var[Union[str, list[str]]]]:
|
) -> tuple[Var[Union[str, list[str]]]]:
|
||||||
"""Handle the on_value_change event.
|
"""Handle the on_value_change event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Any, Literal, Optional, Tuple, Union, overload
|
from typing import Any, Literal, Optional, Union, overload
|
||||||
|
|
||||||
from reflex.components.core.breakpoints import Breakpoints
|
from reflex.components.core.breakpoints import Breakpoints
|
||||||
from reflex.event import EventType
|
from reflex.event import EventType
|
||||||
@ -15,7 +15,7 @@ from ..base import RadixThemesComponent
|
|||||||
|
|
||||||
def on_value_change(
|
def on_value_change(
|
||||||
value: Var[Union[str, list[str]]],
|
value: Var[Union[str, list[str]]],
|
||||||
) -> Tuple[Var[Union[str, list[str]]]]: ...
|
) -> tuple[Var[Union[str, list[str]]]]: ...
|
||||||
|
|
||||||
class SegmentedControlRoot(RadixThemesComponent):
|
class SegmentedControlRoot(RadixThemesComponent):
|
||||||
@overload
|
@overload
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import enum
|
import enum
|
||||||
from typing import Any, Dict, Literal, Optional, Tuple, Union
|
from typing import Any, Dict, Literal, Optional, Union
|
||||||
|
|
||||||
from reflex.base import Base
|
from reflex.base import Base
|
||||||
from reflex.components.component import Component, NoSSRComponent
|
from reflex.components.component import Component, NoSSRComponent
|
||||||
@ -68,7 +68,7 @@ class EditorOptions(Base):
|
|||||||
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_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]:
|
||||||
"""A helper function to specify the on_blur event handler.
|
"""A helper function to specify the on_blur event handler.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -83,7 +83,7 @@ def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]:
|
|||||||
|
|
||||||
def on_paste_spec(
|
def on_paste_spec(
|
||||||
e: Var, clean_data: Var[str], max_char_count: Var[bool]
|
e: Var, clean_data: Var[str], max_char_count: Var[bool]
|
||||||
) -> Tuple[Var[str], Var[bool]]:
|
) -> tuple[Var[str], Var[bool]]:
|
||||||
"""A helper function to specify the on_paste event handler.
|
"""A helper function to specify the on_paste event handler.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This file was generated by `reflex/utils/pyi_generator.py`!
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
import enum
|
import enum
|
||||||
from typing import Any, Dict, Literal, Optional, Tuple, Union, overload
|
from typing import Any, Dict, Literal, Optional, Union, overload
|
||||||
|
|
||||||
from reflex.base import Base
|
from reflex.base import Base
|
||||||
from reflex.components.component import NoSSRComponent
|
from reflex.components.component import NoSSRComponent
|
||||||
@ -44,10 +44,10 @@ class EditorOptions(Base):
|
|||||||
rtl: Optional[bool]
|
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_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]: ...
|
||||||
def on_paste_spec(
|
def on_paste_spec(
|
||||||
e: Var, clean_data: Var[str], max_char_count: Var[bool]
|
e: Var, clean_data: Var[str], max_char_count: Var[bool]
|
||||||
) -> Tuple[Var[str], Var[bool]]: ...
|
) -> tuple[Var[str], Var[bool]]: ...
|
||||||
|
|
||||||
class Editor(NoSSRComponent):
|
class Editor(NoSSRComponent):
|
||||||
def add_imports(self) -> ImportDict: ...
|
def add_imports(self) -> ImportDict: ...
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import inspect
|
import inspect
|
||||||
from typing import TYPE_CHECKING, Any, Callable, Iterable, Tuple, Type, Union, get_args
|
from typing import TYPE_CHECKING, Any, Callable, Iterable, Type, Union, get_args
|
||||||
|
|
||||||
from reflex.components.tags.tag import Tag
|
from reflex.components.tags.tag import Tag
|
||||||
from reflex.vars import LiteralArrayVar, Var, get_unique_variable_name
|
from reflex.vars import LiteralArrayVar, Var, get_unique_variable_name
|
||||||
@ -41,7 +41,7 @@ class IterTag(Tag):
|
|||||||
try:
|
try:
|
||||||
if iterable._var_type.mro()[0] is dict:
|
if iterable._var_type.mro()[0] is dict:
|
||||||
# Arg is a tuple of (key, value).
|
# Arg is a tuple of (key, value).
|
||||||
return Tuple[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
|
return tuple[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
|
||||||
elif iterable._var_type.mro()[0] is tuple:
|
elif iterable._var_type.mro()[0] is tuple:
|
||||||
# Arg is a union of any possible values in the tuple.
|
# Arg is a union of any possible values in the tuple.
|
||||||
return Union[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
|
return Union[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
|
||||||
|
@ -83,7 +83,7 @@ class Tag:
|
|||||||
"""Iterate over the tag's fields.
|
"""Iterate over the tag's fields.
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
Tuple[str, Any]: The field name and value.
|
tuple[str, Any]: The field name and value.
|
||||||
"""
|
"""
|
||||||
for field in dataclasses.fields(self):
|
for field in dataclasses.fields(self):
|
||||||
rendered_value = render_prop(getattr(self, field.name))
|
rendered_value = render_prop(getattr(self, field.name))
|
||||||
|
@ -9,7 +9,7 @@ import sys
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Tuple
|
from typing import Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import tomlkit
|
import tomlkit
|
||||||
@ -927,7 +927,7 @@ def _validate_url_with_protocol_prefix(url: str | None) -> bool:
|
|||||||
return not url or (url.startswith("http://") or url.startswith("https://"))
|
return not url or (url.startswith("http://") or url.startswith("https://"))
|
||||||
|
|
||||||
|
|
||||||
def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
|
def _get_file_from_prompt_in_loop() -> tuple[bytes, str] | None:
|
||||||
image_file = file_extension = None
|
image_file = file_extension = None
|
||||||
while image_file is None:
|
while image_file is None:
|
||||||
image_filepath = Path(
|
image_filepath = Path(
|
||||||
|
@ -18,7 +18,6 @@ from typing import (
|
|||||||
Optional,
|
Optional,
|
||||||
Protocol,
|
Protocol,
|
||||||
Sequence,
|
Sequence,
|
||||||
Tuple,
|
|
||||||
Type,
|
Type,
|
||||||
TypedDict,
|
TypedDict,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
@ -260,14 +259,14 @@ class EventSpec(EventActionsMixin):
|
|||||||
client_handler_name: str = dataclasses.field(default="")
|
client_handler_name: str = dataclasses.field(default="")
|
||||||
|
|
||||||
# The arguments to pass to the function.
|
# The arguments to pass to the function.
|
||||||
args: Tuple[Tuple[Var, Var], ...] = dataclasses.field(default_factory=tuple)
|
args: tuple[tuple[Var, Var], ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
handler: EventHandler,
|
handler: EventHandler,
|
||||||
event_actions: dict[str, Union[bool, int]] | None = None,
|
event_actions: dict[str, Union[bool, int]] | None = None,
|
||||||
client_handler_name: str = "",
|
client_handler_name: str = "",
|
||||||
args: Tuple[Tuple[Var, Var], ...] = (),
|
args: tuple[tuple[Var, Var], ...] = (),
|
||||||
):
|
):
|
||||||
"""Initialize an EventSpec.
|
"""Initialize an EventSpec.
|
||||||
|
|
||||||
@ -284,7 +283,7 @@ class EventSpec(EventActionsMixin):
|
|||||||
object.__setattr__(self, "client_handler_name", client_handler_name)
|
object.__setattr__(self, "client_handler_name", client_handler_name)
|
||||||
object.__setattr__(self, "args", args or ())
|
object.__setattr__(self, "args", args or ())
|
||||||
|
|
||||||
def with_args(self, args: Tuple[Tuple[Var, Var], ...]) -> EventSpec:
|
def with_args(self, args: tuple[tuple[Var, Var], ...]) -> EventSpec:
|
||||||
"""Copy the event spec, with updated args.
|
"""Copy the event spec, with updated args.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -531,7 +530,7 @@ class JavasciptKeyboardEvent:
|
|||||||
shiftKey: bool = False # noqa: N815
|
shiftKey: bool = False # noqa: N815
|
||||||
|
|
||||||
|
|
||||||
def input_event(e: ObjectVar[JavascriptInputEvent]) -> Tuple[Var[str]]:
|
def input_event(e: ObjectVar[JavascriptInputEvent]) -> tuple[Var[str]]:
|
||||||
"""Get the value from an input event.
|
"""Get the value from an input event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -554,7 +553,7 @@ class KeyInputInfo(TypedDict):
|
|||||||
|
|
||||||
def key_event(
|
def key_event(
|
||||||
e: ObjectVar[JavasciptKeyboardEvent],
|
e: ObjectVar[JavasciptKeyboardEvent],
|
||||||
) -> Tuple[Var[str], Var[KeyInputInfo]]:
|
) -> tuple[Var[str], Var[KeyInputInfo]]:
|
||||||
"""Get the key from a keyboard event.
|
"""Get the key from a keyboard event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -576,7 +575,7 @@ def key_event(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def no_args_event_spec() -> Tuple[()]:
|
def no_args_event_spec() -> tuple[()]:
|
||||||
"""Empty event handler.
|
"""Empty event handler.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -597,7 +596,7 @@ U = TypeVar("U")
|
|||||||
class IdentityEventReturn(Generic[T], Protocol):
|
class IdentityEventReturn(Generic[T], Protocol):
|
||||||
"""Protocol for an identity event return."""
|
"""Protocol for an identity event return."""
|
||||||
|
|
||||||
def __call__(self, *values: Var[T]) -> Tuple[Var[T], ...]:
|
def __call__(self, *values: Var[T]) -> tuple[Var[T], ...]:
|
||||||
"""Return the input values.
|
"""Return the input values.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -612,13 +611,13 @@ class IdentityEventReturn(Generic[T], Protocol):
|
|||||||
@overload
|
@overload
|
||||||
def passthrough_event_spec( # pyright: ignore [reportOverlappingOverload]
|
def passthrough_event_spec( # pyright: ignore [reportOverlappingOverload]
|
||||||
event_type: Type[T], /
|
event_type: Type[T], /
|
||||||
) -> Callable[[Var[T]], Tuple[Var[T]]]: ...
|
) -> Callable[[Var[T]], tuple[Var[T]]]: ...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def passthrough_event_spec(
|
def passthrough_event_spec(
|
||||||
event_type_1: Type[T], event_type2: Type[U], /
|
event_type_1: Type[T], event_type2: Type[U], /
|
||||||
) -> Callable[[Var[T], Var[U]], Tuple[Var[T], Var[U]]]: ...
|
) -> Callable[[Var[T], Var[U]], tuple[Var[T], Var[U]]]: ...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -635,11 +634,11 @@ def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]: #
|
|||||||
A function that returns the input event as output.
|
A function that returns the input event as output.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def inner(*values: Var[T]) -> Tuple[Var[T], ...]:
|
def inner(*values: Var[T]) -> tuple[Var[T], ...]:
|
||||||
return values
|
return values
|
||||||
|
|
||||||
inner_type = tuple(Var[event_type] for event_type in event_types)
|
inner_type = tuple(Var[event_type] for event_type in event_types)
|
||||||
return_annotation = Tuple[inner_type]
|
return_annotation = tuple[inner_type]
|
||||||
|
|
||||||
inner.__signature__ = inspect.signature(inner).replace( # pyright: ignore [reportFunctionMemberAccess]
|
inner.__signature__ = inspect.signature(inner).replace( # pyright: ignore [reportFunctionMemberAccess]
|
||||||
parameters=[
|
parameters=[
|
||||||
|
@ -354,7 +354,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
class_subclasses: ClassVar[set[Type[BaseState]]] = set()
|
class_subclasses: ClassVar[set[Type[BaseState]]] = set()
|
||||||
|
|
||||||
# Mapping of var name to set of (state_full_name, var_name) that depend on it.
|
# Mapping of var name to set of (state_full_name, var_name) that depend on it.
|
||||||
_var_dependencies: ClassVar[Dict[str, set[Tuple[str, str]]]] = {}
|
_var_dependencies: ClassVar[Dict[str, set[tuple[str, str]]]] = {}
|
||||||
|
|
||||||
# Set of vars which always need to be recomputed
|
# Set of vars which always need to be recomputed
|
||||||
_always_dirty_computed_vars: ClassVar[set[str]] = set()
|
_always_dirty_computed_vars: ClassVar[set[str]] = set()
|
||||||
@ -2144,7 +2144,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
|
|
||||||
def _field_tuple(
|
def _field_tuple(
|
||||||
field_name: str,
|
field_name: str,
|
||||||
) -> Tuple[str, str, Any, Union[bool, None], Any]:
|
) -> tuple[str, str, Any, Union[bool, None], Any]:
|
||||||
model_field = cls.__fields__[field_name]
|
model_field = cls.__fields__[field_name]
|
||||||
return (
|
return (
|
||||||
field_name,
|
field_name,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Literal, Tuple, Type
|
from typing import Any, Literal, Type
|
||||||
|
|
||||||
from reflex import constants
|
from reflex import constants
|
||||||
from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
|
from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
|
||||||
@ -226,7 +226,7 @@ def convert(
|
|||||||
return out, var_data
|
return out, var_data
|
||||||
|
|
||||||
|
|
||||||
def format_style_key(key: str) -> Tuple[str, ...]:
|
def format_style_key(key: str) -> tuple[str, ...]:
|
||||||
"""Convert style keys to camel case and convert shorthand
|
"""Convert style keys to camel case and convert shorthand
|
||||||
styles names to their corresponding css names.
|
styles names to their corresponding css names.
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import DefaultDict, Optional, Tuple, Union
|
from typing import DefaultDict, Optional, Union
|
||||||
|
|
||||||
|
|
||||||
def merge_imports(
|
def merge_imports(
|
||||||
@ -134,4 +134,4 @@ class ImportVar:
|
|||||||
ImportTypes = Union[str, ImportVar, list[Union[str, ImportVar]], list[ImportVar]]
|
ImportTypes = Union[str, ImportVar, list[Union[str, ImportVar]], list[ImportVar]]
|
||||||
ImportDict = dict[str, ImportTypes]
|
ImportDict = dict[str, ImportTypes]
|
||||||
ParsedImportDict = dict[str, list[ImportVar]]
|
ParsedImportDict = dict[str, list[ImportVar]]
|
||||||
ImmutableParsedImportDict = Tuple[Tuple[str, Tuple[ImportVar, ...]], ...]
|
ImmutableParsedImportDict = tuple[tuple[str, tuple[ImportVar, ...]], ...]
|
||||||
|
@ -529,8 +529,12 @@ def _generate_component_create_functiondef(
|
|||||||
id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]"
|
id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]"
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(annotation, str) and annotation.startswith("Tuple["):
|
if isinstance(annotation, str) and annotation.lower().startswith("tuple["):
|
||||||
inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]")
|
inside_of_tuple = (
|
||||||
|
annotation.removeprefix("tuple[")
|
||||||
|
.removeprefix("Tuple[")
|
||||||
|
.removesuffix("]")
|
||||||
|
)
|
||||||
|
|
||||||
if inside_of_tuple == "()":
|
if inside_of_tuple == "()":
|
||||||
return ast.Name(id="EventType[()]")
|
return ast.Name(id="EventType[()]")
|
||||||
|
@ -16,7 +16,6 @@ from typing import (
|
|||||||
Literal,
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
Set,
|
Set,
|
||||||
Tuple,
|
|
||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
@ -114,7 +113,7 @@ def serializer(
|
|||||||
@overload
|
@overload
|
||||||
def serialize(
|
def serialize(
|
||||||
value: Any, get_type: Literal[True]
|
value: Any, get_type: Literal[True]
|
||||||
) -> Tuple[Optional[SerializedType], Optional[types.GenericType]]: ...
|
) -> tuple[Optional[SerializedType], Optional[types.GenericType]]: ...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -129,7 +128,7 @@ def serialize(
|
|||||||
value: Any, get_type: bool = False
|
value: Any, get_type: bool = False
|
||||||
) -> Union[
|
) -> Union[
|
||||||
Optional[SerializedType],
|
Optional[SerializedType],
|
||||||
Tuple[Optional[SerializedType], Optional[types.GenericType]],
|
tuple[Optional[SerializedType], Optional[types.GenericType]],
|
||||||
]:
|
]:
|
||||||
"""Serialize the value to a JSON string.
|
"""Serialize the value to a JSON string.
|
||||||
|
|
||||||
|
@ -805,7 +805,7 @@ StateBases = get_base_class(StateVar)
|
|||||||
StateIterBases = get_base_class(StateIterVar)
|
StateIterBases = get_base_class(StateIterVar)
|
||||||
|
|
||||||
|
|
||||||
def safe_issubclass(cls: Type, cls_check: Type | Tuple[Type, ...]):
|
def safe_issubclass(cls: Type, cls_check: Type | tuple[Type, ...]):
|
||||||
"""Check if a class is a subclass of another class. Returns False if internal error occurs.
|
"""Check if a class is a subclass of another class. Returns False if internal error occurs.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -100,11 +100,11 @@ class VarSubclassEntry:
|
|||||||
|
|
||||||
var_subclass: Type[Var]
|
var_subclass: Type[Var]
|
||||||
to_var_subclass: Type[ToOperation]
|
to_var_subclass: Type[ToOperation]
|
||||||
python_types: Tuple[GenericType, ...]
|
python_types: tuple[GenericType, ...]
|
||||||
|
|
||||||
|
|
||||||
_var_subclasses: list[VarSubclassEntry] = []
|
_var_subclasses: list[VarSubclassEntry] = []
|
||||||
_var_literal_subclasses: list[Tuple[Type[LiteralVar], VarSubclassEntry]] = []
|
_var_literal_subclasses: list[tuple[Type[LiteralVar], VarSubclassEntry]] = []
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(
|
@dataclasses.dataclass(
|
||||||
@ -124,10 +124,10 @@ class VarData:
|
|||||||
imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple)
|
imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
# Hooks that need to be present in the component to render this var
|
# Hooks that need to be present in the component to render this var
|
||||||
hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple)
|
hooks: tuple[str, ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
# Dependencies of the var
|
# Dependencies of the var
|
||||||
deps: Tuple[Var, ...] = dataclasses.field(default_factory=tuple)
|
deps: tuple[Var, ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
# Position of the hook in the component
|
# Position of the hook in the component
|
||||||
position: Hooks.HookPosition | None = None
|
position: Hooks.HookPosition | None = None
|
||||||
@ -429,7 +429,7 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
|
|
||||||
def __init_subclass__(
|
def __init_subclass__(
|
||||||
cls,
|
cls,
|
||||||
python_types: Tuple[GenericType, ...] | GenericType = types.Unset(),
|
python_types: tuple[GenericType, ...] | GenericType = types.Unset(),
|
||||||
default_type: GenericType = types.Unset(),
|
default_type: GenericType = types.Unset(),
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
@ -1680,7 +1680,7 @@ def figure_out_type(value: Any) -> types.GenericType:
|
|||||||
if isinstance(value, set):
|
if isinstance(value, set):
|
||||||
return set[unionize(*(figure_out_type(v) for v in value))]
|
return set[unionize(*(figure_out_type(v) for v in value))]
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
return Tuple[unionize(*(figure_out_type(v) for v in value)), ...]
|
return tuple[unionize(*(figure_out_type(v) for v in value)), ...]
|
||||||
if isinstance(value, Mapping):
|
if isinstance(value, Mapping):
|
||||||
return Mapping[
|
return Mapping[
|
||||||
unionize(*(figure_out_type(k) for k in value)),
|
unionize(*(figure_out_type(k) for k in value)),
|
||||||
@ -2720,7 +2720,7 @@ class CustomVarOperation(CachedVarOperation, Var[T]):
|
|||||||
|
|
||||||
_name: str = dataclasses.field(default="")
|
_name: str = dataclasses.field(default="")
|
||||||
|
|
||||||
_args: Tuple[Tuple[str, Var], ...] = dataclasses.field(default_factory=tuple)
|
_args: tuple[tuple[str, Var], ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
_return: CustomVarOperationReturn[T] = dataclasses.field(
|
_return: CustomVarOperationReturn[T] = dataclasses.field(
|
||||||
default_factory=lambda: CustomVarOperationReturn.create("")
|
default_factory=lambda: CustomVarOperationReturn.create("")
|
||||||
@ -2752,7 +2752,7 @@ class CustomVarOperation(CachedVarOperation, Var[T]):
|
|||||||
def create(
|
def create(
|
||||||
cls,
|
cls,
|
||||||
name: str,
|
name: str,
|
||||||
args: Tuple[Tuple[str, Var], ...],
|
args: tuple[tuple[str, Var], ...],
|
||||||
return_var: CustomVarOperationReturn[T],
|
return_var: CustomVarOperationReturn[T],
|
||||||
_var_data: VarData | None = None,
|
_var_data: VarData | None = None,
|
||||||
) -> CustomVarOperation[T]:
|
) -> CustomVarOperation[T]:
|
||||||
@ -3269,7 +3269,7 @@ class Field(Generic[FIELD_TYPE]):
|
|||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __get__(
|
def __get__(
|
||||||
self: Field[list[V]] | Field[set[V]] | Field[Tuple[V, ...]],
|
self: Field[list[V]] | Field[set[V]] | Field[tuple[V, ...]],
|
||||||
instance: None,
|
instance: None,
|
||||||
owner: Any,
|
owner: Any,
|
||||||
) -> ArrayVar[list[V]]: ...
|
) -> ArrayVar[list[V]]: ...
|
||||||
|
@ -13,7 +13,6 @@ from typing import (
|
|||||||
ParamSpec,
|
ParamSpec,
|
||||||
Protocol,
|
Protocol,
|
||||||
Sequence,
|
Sequence,
|
||||||
Tuple,
|
|
||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
@ -244,7 +243,7 @@ class VarOperationCall(Generic[P, R], CachedVarOperation, Var[R]):
|
|||||||
"""Base class for immutable vars that are the result of a function call."""
|
"""Base class for immutable vars that are the result of a function call."""
|
||||||
|
|
||||||
_func: Optional[FunctionVar[ReflexCallable[P, R]]] = dataclasses.field(default=None)
|
_func: Optional[FunctionVar[ReflexCallable[P, R]]] = dataclasses.field(default=None)
|
||||||
_args: Tuple[Union[Var, Any], ...] = dataclasses.field(default_factory=tuple)
|
_args: tuple[Union[Var, Any], ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
@cached_property_no_lock
|
@cached_property_no_lock
|
||||||
def _cached_var_name(self) -> str:
|
def _cached_var_name(self) -> str:
|
||||||
@ -306,7 +305,7 @@ class VarOperationCall(Generic[P, R], CachedVarOperation, Var[R]):
|
|||||||
class DestructuredArg:
|
class DestructuredArg:
|
||||||
"""Class for destructured arguments."""
|
"""Class for destructured arguments."""
|
||||||
|
|
||||||
fields: Tuple[str, ...] = ()
|
fields: tuple[str, ...] = ()
|
||||||
rest: Optional[str] = None
|
rest: Optional[str] = None
|
||||||
|
|
||||||
def to_javascript(self) -> str:
|
def to_javascript(self) -> str:
|
||||||
@ -328,7 +327,7 @@ class DestructuredArg:
|
|||||||
class FunctionArgs:
|
class FunctionArgs:
|
||||||
"""Class for function arguments."""
|
"""Class for function arguments."""
|
||||||
|
|
||||||
args: Tuple[Union[str, DestructuredArg], ...] = ()
|
args: tuple[Union[str, DestructuredArg], ...] = ()
|
||||||
rest: Optional[str] = None
|
rest: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,17 +5,7 @@ from __future__ import annotations
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
import typing
|
import typing
|
||||||
from inspect import isclass
|
from inspect import isclass
|
||||||
from typing import (
|
from typing import Any, Mapping, NoReturn, Type, TypeVar, Union, get_args, overload
|
||||||
Any,
|
|
||||||
Mapping,
|
|
||||||
NoReturn,
|
|
||||||
Tuple,
|
|
||||||
Type,
|
|
||||||
TypeVar,
|
|
||||||
Union,
|
|
||||||
get_args,
|
|
||||||
overload,
|
|
||||||
)
|
|
||||||
|
|
||||||
from typing_extensions import is_typeddict
|
from typing_extensions import is_typeddict
|
||||||
|
|
||||||
@ -109,7 +99,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
|
|||||||
@overload
|
@overload
|
||||||
def entries(
|
def entries(
|
||||||
self: ObjectVar[Mapping[Any, VALUE_TYPE]],
|
self: ObjectVar[Mapping[Any, VALUE_TYPE]],
|
||||||
) -> ArrayVar[list[Tuple[str, VALUE_TYPE]]]: ...
|
) -> ArrayVar[list[tuple[str, VALUE_TYPE]]]: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def entries(self) -> ArrayVar: ...
|
def entries(self) -> ArrayVar: ...
|
||||||
@ -458,7 +448,7 @@ def object_entries_operation(value: ObjectVar):
|
|||||||
"""
|
"""
|
||||||
return var_operation_return(
|
return var_operation_return(
|
||||||
js_expression=f"Object.entries({value})",
|
js_expression=f"Object.entries({value})",
|
||||||
var_type=list[Tuple[str, value._value_type()]],
|
var_type=list[tuple[str, value._value_type()]],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ from typing import (
|
|||||||
Literal,
|
Literal,
|
||||||
NoReturn,
|
NoReturn,
|
||||||
Sequence,
|
Sequence,
|
||||||
Tuple,
|
|
||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
@ -799,7 +798,7 @@ class LiteralStringVar(LiteralVar, StringVar[str]):
|
|||||||
class ConcatVarOperation(CachedVarOperation, StringVar[str]):
|
class ConcatVarOperation(CachedVarOperation, StringVar[str]):
|
||||||
"""Representing a concatenation of literal string vars."""
|
"""Representing a concatenation of literal string vars."""
|
||||||
|
|
||||||
_var_value: Tuple[Var, ...] = dataclasses.field(default_factory=tuple)
|
_var_value: tuple[Var, ...] = dataclasses.field(default_factory=tuple)
|
||||||
|
|
||||||
@cached_property_no_lock
|
@cached_property_no_lock
|
||||||
def _cached_var_name(self) -> str:
|
def _cached_var_name(self) -> str:
|
||||||
@ -957,41 +956,41 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)):
|
|||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: (
|
self: (
|
||||||
ArrayVar[Tuple[int, OTHER_TUPLE]]
|
ArrayVar[tuple[int, OTHER_TUPLE]]
|
||||||
| ArrayVar[Tuple[float, OTHER_TUPLE]]
|
| ArrayVar[tuple[float, OTHER_TUPLE]]
|
||||||
| ArrayVar[Tuple[int | float, OTHER_TUPLE]]
|
| ArrayVar[tuple[int | float, OTHER_TUPLE]]
|
||||||
),
|
),
|
||||||
i: Literal[0, -2],
|
i: Literal[0, -2],
|
||||||
) -> NumberVar: ...
|
) -> NumberVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ArrayVar[Tuple[Any, bool]], i: Literal[1, -1]
|
self: ArrayVar[tuple[Any, bool]], i: Literal[1, -1]
|
||||||
) -> BooleanVar: ...
|
) -> BooleanVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: (
|
self: (
|
||||||
ArrayVar[Tuple[Any, int]]
|
ArrayVar[tuple[Any, int]]
|
||||||
| ArrayVar[Tuple[Any, float]]
|
| ArrayVar[tuple[Any, float]]
|
||||||
| ArrayVar[Tuple[Any, int | float]]
|
| ArrayVar[tuple[Any, int | float]]
|
||||||
),
|
),
|
||||||
i: Literal[1, -1],
|
i: Literal[1, -1],
|
||||||
) -> NumberVar: ...
|
) -> NumberVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ArrayVar[Tuple[str, Any]], i: Literal[0, -2]
|
self: ArrayVar[tuple[str, Any]], i: Literal[0, -2]
|
||||||
) -> StringVar: ...
|
) -> StringVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ArrayVar[Tuple[Any, str]], i: Literal[1, -1]
|
self: ArrayVar[tuple[Any, str]], i: Literal[1, -1]
|
||||||
) -> StringVar: ...
|
) -> StringVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ArrayVar[Tuple[bool, Any]], i: Literal[0, -2]
|
self: ArrayVar[tuple[bool, Any]], i: Literal[0, -2]
|
||||||
) -> BooleanVar: ...
|
) -> BooleanVar: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -1022,15 +1021,15 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)):
|
|||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[KEY_TYPE, VALUE_TYPE]],
|
self: ARRAY_VAR_OF_LIST_ELEMENT[tuple[KEY_TYPE, VALUE_TYPE]],
|
||||||
i: int | NumberVar,
|
i: int | NumberVar,
|
||||||
) -> ArrayVar[Tuple[KEY_TYPE, VALUE_TYPE]]: ...
|
) -> ArrayVar[tuple[KEY_TYPE, VALUE_TYPE]]: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]],
|
self: ARRAY_VAR_OF_LIST_ELEMENT[tuple[INNER_ARRAY_VAR, ...]],
|
||||||
i: int | NumberVar,
|
i: int | NumberVar,
|
||||||
) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ...
|
) -> ArrayVar[tuple[INNER_ARRAY_VAR, ...]]: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__(
|
||||||
|
@ -8,7 +8,6 @@ import argparse
|
|||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from typing import Tuple
|
|
||||||
|
|
||||||
# psutil is already a dependency of Reflex itself - so it's OK to use
|
# psutil is already a dependency of Reflex itself - so it's OK to use
|
||||||
import psutil
|
import psutil
|
||||||
@ -23,7 +22,7 @@ def _pid_exists(pid: int):
|
|||||||
return pid in psutil.pids()
|
return pid in psutil.pids()
|
||||||
|
|
||||||
|
|
||||||
def _wait_for_port(port: int, server_pid: int, timeout: float) -> Tuple[bool, str]:
|
def _wait_for_port(port: int, server_pid: int, timeout: float) -> tuple[bool, str]:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
print(f"Waiting for up to {timeout} seconds for port {port} to start listening.") # noqa: T201
|
print(f"Waiting for up to {timeout} seconds for port {port} to start listening.") # noqa: T201
|
||||||
while True:
|
while True:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Tuple, Union
|
from typing import Union
|
||||||
|
|
||||||
import pydantic.v1
|
import pydantic.v1
|
||||||
import pytest
|
import pytest
|
||||||
@ -46,13 +46,13 @@ class ForEachState(BaseState):
|
|||||||
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"}]}
|
"primary": {"red": [{"shade": "dark"}]}
|
||||||
}
|
}
|
||||||
color_tuple: Tuple[str, str] = (
|
color_tuple: tuple[str, str] = (
|
||||||
"red",
|
"red",
|
||||||
"yellow",
|
"yellow",
|
||||||
)
|
)
|
||||||
colors_set: set[str] = {"red", "green"}
|
colors_set: set[str] = {"red", "green"}
|
||||||
bad_annotation_list: list = [["red", "orange"], ["yellow", "blue"]]
|
bad_annotation_list: list = [["red", "orange"], ["yellow", "blue"]]
|
||||||
color_index_tuple: Tuple[int, str] = (0, "red")
|
color_index_tuple: tuple[int, str] = (0, "red")
|
||||||
|
|
||||||
default_factory_list: list[ForEachTag] = pydantic.v1.Field(default_factory=list)
|
default_factory_list: list[ForEachTag] = pydantic.v1.Field(default_factory=list)
|
||||||
|
|
||||||
@ -92,17 +92,17 @@ def display_shade(color):
|
|||||||
|
|
||||||
|
|
||||||
def display_primary_colors(color):
|
def display_primary_colors(color):
|
||||||
assert color._var_type == Tuple[str, str]
|
assert color._var_type == tuple[str, str]
|
||||||
return box(text(color[0]), text(color[1]))
|
return box(text(color[0]), text(color[1]))
|
||||||
|
|
||||||
|
|
||||||
def display_color_with_shades(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]))
|
return box(text(color[0]), text(color[1][0]))
|
||||||
|
|
||||||
|
|
||||||
def display_nested_color_with_shades(color):
|
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"]))
|
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):
|
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)))
|
return box(text(foreach(color[1], show_shade)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import unittest.mock
|
|||||||
import uuid
|
import uuid
|
||||||
from contextlib import nullcontext as does_not_raise
|
from contextlib import nullcontext as does_not_raise
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Generator, Tuple, Type
|
from typing import Generator, Type
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
import pytest
|
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(
|
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,
|
list_mutation_state: State,
|
||||||
token: str,
|
token: str,
|
||||||
):
|
):
|
||||||
@ -695,7 +695,7 @@ async def test_list_mutation_detection__plain_list(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_dict_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,
|
dict_mutation_state: State,
|
||||||
token: str,
|
token: str,
|
||||||
):
|
):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import typing
|
import typing
|
||||||
from typing import List, Mapping, Optional, Tuple, Union, cast
|
from typing import List, Mapping, Optional, Union, cast
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
@ -483,7 +483,7 @@ def test_dict_contains(var, expected):
|
|||||||
"var",
|
"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="tuple", _var_type=tuple[int, int]).guess_type(),
|
||||||
Var(_js_expr="str", _var_type=str).guess_type(),
|
Var(_js_expr="str", _var_type=str).guess_type(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -506,7 +506,7 @@ def test_var_indexing_lists(var):
|
|||||||
[
|
[
|
||||||
(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(),
|
Var(_js_expr="tuple", _var_type=tuple[int, str]).guess_type(),
|
||||||
[int, str],
|
[int, str],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -611,18 +611,18 @@ def test_computed_var_replace_with_invalid_kwargs():
|
|||||||
Var(_js_expr="lst", _var_type=str).guess_type(),
|
Var(_js_expr="lst", _var_type=str).guess_type(),
|
||||||
Var(_js_expr="float_var", _var_type=float).guess_type(),
|
Var(_js_expr="float_var", _var_type=float).guess_type(),
|
||||||
),
|
),
|
||||||
(Var(_js_expr="str", _var_type=Tuple[str]).guess_type(), [1, 2]),
|
(Var(_js_expr="str", _var_type=tuple[str]).guess_type(), [1, 2]),
|
||||||
(
|
(
|
||||||
Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
|
Var(_js_expr="lst", _var_type=tuple[str]).guess_type(),
|
||||||
{"name": "dict"},
|
{"name": "dict"},
|
||||||
),
|
),
|
||||||
(Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), {"set"}),
|
(Var(_js_expr="lst", _var_type=tuple[str]).guess_type(), {"set"}),
|
||||||
(
|
(
|
||||||
Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
|
Var(_js_expr="lst", _var_type=tuple[str]).guess_type(),
|
||||||
Var(_js_expr="string_var", _var_type=str).guess_type(),
|
Var(_js_expr="string_var", _var_type=str).guess_type(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
|
Var(_js_expr="lst", _var_type=tuple[str]).guess_type(),
|
||||||
Var(_js_expr="float_var", _var_type=float).guess_type(),
|
Var(_js_expr="float_var", _var_type=float).guess_type(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -642,7 +642,7 @@ def test_var_unsupported_indexing_lists(var, index):
|
|||||||
"var",
|
"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(),
|
Var(_js_expr="tuple", _var_type=tuple[int, int]).guess_type(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_var_list_slicing(var):
|
def test_var_list_slicing(var):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Literal, Tuple, Union
|
from typing import Any, Literal, Union
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ def test_validate_literal_error_msg(params, allowed_value_str, value_str):
|
|||||||
"cls,cls_check,expected",
|
"cls,cls_check,expected",
|
||||||
[
|
[
|
||||||
(int, Any, True),
|
(int, Any, True),
|
||||||
(Tuple[int], Any, True),
|
(tuple[int], Any, True),
|
||||||
(list[int], Any, True),
|
(list[int], Any, True),
|
||||||
(int, int, True),
|
(int, int, True),
|
||||||
(int, object, True),
|
(int, object, True),
|
||||||
@ -77,7 +77,7 @@ class ChildGenericDict(GenericDict):
|
|||||||
(int, False),
|
(int, False),
|
||||||
(str, False),
|
(str, False),
|
||||||
(float, False),
|
(float, False),
|
||||||
(Tuple[int], True),
|
(tuple[int], True),
|
||||||
(list[int], True),
|
(list[int], True),
|
||||||
(Union[int, str], True),
|
(Union[int, str], True),
|
||||||
(Union[str, int], True),
|
(Union[str, int], True),
|
||||||
|
Loading…
Reference in New Issue
Block a user