Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use lowercase datatypes typing #4843

Merged
merged 16 commits into from
Mar 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do the same for tuple
adhami3310 committed Feb 18, 2025
commit d0940b9cefa90a28c428c067aba1cc5e1fb4fad6
4 changes: 2 additions & 2 deletions reflex/compiler/compiler.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

from datetime import datetime
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.compiler import templates, utils
@@ -594,7 +594,7 @@ def compile_unevaluated_page(
state: Type[BaseState] | None = None,
style: ComponentStyle | None = None,
theme: Component | None = None,
) -> Tuple[Component, bool]:
) -> tuple[Component, bool]:
"""Compiles an uncompiled page into a component and adds meta information.

Args:
4 changes: 1 addition & 3 deletions reflex/components/base/error_boundary.py
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

from __future__ import annotations

from typing import Tuple

from reflex.components.component import Component
from reflex.components.datadisplay.logo import svg_logo
from reflex.components.el import a, button, details, div, h2, hr, p, pre, summary
@@ -16,7 +14,7 @@

def on_error_spec(
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.

Args:
4 changes: 2 additions & 2 deletions reflex/components/base/error_boundary.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# ------------------- DO NOT EDIT ----------------------
# 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.event import EventType
@@ -13,7 +13,7 @@ from reflex.vars.object import ObjectVar

def on_error_spec(
error: ObjectVar[dict[str, str]], info: ObjectVar[dict[str, str]]
) -> Tuple[Var[str], Var[str]]: ...
) -> tuple[Var[str], Var[str]]: ...

class ErrorBoundary(Component):
@overload
4 changes: 2 additions & 2 deletions reflex/components/core/breakpoints.py
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@

from __future__ import annotations

from typing import Tuple, TypeVar, Union
from typing import TypeVar, Union

breakpoints_values = ["30em", "48em", "62em", "80em", "96em"]
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.

Args:
4 changes: 2 additions & 2 deletions reflex/components/core/clipboard.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Tuple, Union
from typing import Union

from reflex.components.base.fragment import Fragment
from reflex.components.tags.tag import Tag
@@ -21,7 +21,7 @@ class Clipboard(Fragment):
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]]]
4 changes: 2 additions & 2 deletions reflex/components/core/match.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""rx.match."""

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.component import BaseComponent, Component, MemoizationLeaf
@@ -77,7 +77,7 @@ def _create_condition_var(cls, cond: Any) -> Var:
@classmethod
def _process_cases(
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.

Args:
4 changes: 2 additions & 2 deletions reflex/components/core/upload.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from __future__ import annotations

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.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}")


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:
18 changes: 9 additions & 9 deletions reflex/components/datadisplay/dataeditor.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from __future__ import annotations

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.components.component import Component, NoSSRComponent
@@ -260,20 +260,20 @@ class DataEditor(NoSSRComponent):
theme: Var[Union[DataEditorTheme, Dict]]

# 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.
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.
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.
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.
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.
@@ -285,16 +285,16 @@ class DataEditor(NoSSRComponent):
on_group_header_renamed: EventHandler[passthrough_event_spec(str, str)]

# 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.
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.
on_header_menu_click: EventHandler[passthrough_event_spec(int, Rectangle)]

# 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.
on_delete: EventHandler[passthrough_event_spec(GridSelection)]
6 changes: 3 additions & 3 deletions reflex/components/el/elements/forms.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from __future__ import annotations

from hashlib import md5
from typing import Any, Iterator, Literal, Tuple, Union
from typing import Any, Iterator, Literal, Union

from jinja2 import Environment

@@ -104,7 +104,7 @@ class Fieldset(Element):
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.

Returns:
@@ -113,7 +113,7 @@ def on_submit_event_spec() -> Tuple[Var[dict[str, Any]]]:
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.

Returns:
6 changes: 3 additions & 3 deletions reflex/components/el/elements/forms.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# ------------------- DO NOT EDIT ----------------------
# 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

@@ -634,8 +634,8 @@ class Fieldset(Element):
"""
...

def on_submit_event_spec() -> Tuple[Var[dict[str, Any]]]: ...
def on_submit_string_event_spec() -> Tuple[Var[dict[str, str]]]: ...
def on_submit_event_spec() -> tuple[Var[dict[str, Any]]]: ...
def on_submit_string_event_spec() -> tuple[Var[dict[str, str]]]: ...

class Form(BaseHTML):
@overload
4 changes: 2 additions & 2 deletions reflex/components/plotly/plotly.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

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.core.cond import color_mode_cond
@@ -21,7 +21,7 @@
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:
4 changes: 2 additions & 2 deletions reflex/components/radix/primitives/accordion.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

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.core.colors import color
@@ -72,7 +72,7 @@ def _exclude_props(self) -> list[str]:
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:
4 changes: 2 additions & 2 deletions reflex/components/radix/primitives/accordion.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# ------------------- DO NOT EDIT ----------------------
# 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.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): ...
4 changes: 2 additions & 2 deletions reflex/components/radix/primitives/slider.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

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.radix.primitives.base import RadixPrimitiveComponentWithClassName
@@ -21,7 +21,7 @@ class SliderComponent(RadixPrimitiveComponentWithClassName):

def on_value_event_spec(
value: Var[list[int]],
) -> Tuple[Var[list[int]]]:
) -> tuple[Var[list[int]]]:
"""Event handler spec for the value event.

Args:
4 changes: 2 additions & 2 deletions reflex/components/radix/primitives/slider.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# ------------------- DO NOT EDIT ----------------------
# 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.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: ...
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from __future__ import annotations

from types import SimpleNamespace
from typing import Literal, Tuple, Union
from typing import Literal, Union

from reflex.components.core.breakpoints import Responsive
from reflex.event import EventHandler
@@ -14,7 +14,7 @@

def on_value_change(
value: Var[Union[str, list[str]]],
) -> Tuple[Var[Union[str, list[str]]]]:
) -> tuple[Var[Union[str, list[str]]]]:
"""Handle the on_value_change event.

Args:
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
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.event import EventType
@@ -15,7 +15,7 @@ from ..base import RadixThemesComponent

def on_value_change(
value: Var[Union[str, list[str]]],
) -> Tuple[Var[Union[str, list[str]]]]: ...
) -> tuple[Var[Union[str, list[str]]]]: ...

class SegmentedControlRoot(RadixThemesComponent):
@overload
6 changes: 3 additions & 3 deletions reflex/components/suneditor/editor.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from __future__ import annotations

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.components.component import Component, NoSSRComponent
@@ -68,7 +68,7 @@ class EditorOptions(Base):
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.

Args:
@@ -83,7 +83,7 @@ def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]:

def on_paste_spec(
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.

Args:
Loading