removed even more optionals
This commit is contained in:
parent
035e6a0bbf
commit
a6b9f4f1c8
@ -26,7 +26,6 @@ from typing import (
|
||||
Coroutine,
|
||||
Dict,
|
||||
MutableMapping,
|
||||
Optional,
|
||||
Type,
|
||||
Union,
|
||||
get_args,
|
||||
@ -360,7 +359,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
||||
html_lang: str | None = None
|
||||
|
||||
# Attributes to add to the html root tag of every page.
|
||||
html_custom_attrs: Optional[dict[str, str]] = None
|
||||
html_custom_attrs: dict[str, str] | None = None
|
||||
|
||||
# A map from a route to an unevaluated page.
|
||||
_unevaluated_pages: dict[str, UnevaluatedPage] = dataclasses.field(
|
||||
@ -374,7 +373,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
||||
_api: FastAPI | None = None
|
||||
|
||||
# The state class to use for the app.
|
||||
_state: Optional[Type[BaseState]] = None
|
||||
_state: Type[BaseState] | None = None
|
||||
|
||||
# Class to manage many client states.
|
||||
_state_manager: StateManager | None = None
|
||||
@ -985,9 +984,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
||||
for render, kwargs in DECORATED_PAGES[get_config().app_name]:
|
||||
self.add_page(render, **kwargs)
|
||||
|
||||
def _validate_var_dependencies(
|
||||
self, state: Optional[Type[BaseState]] = None
|
||||
) -> None:
|
||||
def _validate_var_dependencies(self, state: Type[BaseState] | None = None) -> None:
|
||||
"""Validate the dependencies of the vars in the app.
|
||||
|
||||
Args:
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Iterable, Optional, Sequence, Type
|
||||
from typing import TYPE_CHECKING, Iterable, Sequence, Type
|
||||
|
||||
from reflex import constants
|
||||
from reflex.compiler import templates, utils
|
||||
@ -94,7 +94,7 @@ def _compile_theme(theme: str) -> str:
|
||||
return templates.THEME.render(theme=theme)
|
||||
|
||||
|
||||
def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None) -> str:
|
||||
def _compile_contexts(state: Type[BaseState] | None, theme: Component | None) -> str:
|
||||
"""Compile the initial state and contexts.
|
||||
|
||||
Args:
|
||||
@ -353,7 +353,7 @@ def _compile_tailwind(
|
||||
def compile_document_root(
|
||||
head_components: list[Component],
|
||||
html_lang: str | None = None,
|
||||
html_custom_attrs: Optional[dict[str, Var | str]] = None,
|
||||
html_custom_attrs: dict[str, Var | str] | None = None,
|
||||
) -> tuple[str, str]:
|
||||
"""Compile the document root.
|
||||
|
||||
@ -415,7 +415,7 @@ def compile_theme(style: ComponentStyle) -> tuple[str, str]:
|
||||
|
||||
|
||||
def compile_contexts(
|
||||
state: Optional[Type[BaseState]],
|
||||
state: Type[BaseState] | None,
|
||||
theme: Component | None,
|
||||
) -> tuple[str, str]:
|
||||
"""Compile the initial state / context.
|
||||
@ -681,7 +681,7 @@ class ExecutorSafeFunctions:
|
||||
|
||||
COMPONENTS: dict[str, BaseComponent] = {}
|
||||
UNCOMPILED_PAGES: dict[str, UnevaluatedPage] = {}
|
||||
STATE: Optional[Type[BaseState]] = None
|
||||
STATE: Type[BaseState] | None = None
|
||||
|
||||
@classmethod
|
||||
def compile_page(cls, route: str) -> tuple[str, str]:
|
||||
|
@ -7,7 +7,7 @@ import concurrent.futures
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Optional, Type
|
||||
from typing import Any, Callable, Type
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pydantic.v1.fields import ModelField
|
||||
@ -346,7 +346,7 @@ def compile_custom_component(
|
||||
def create_document_root(
|
||||
head_components: list[Component] | None = None,
|
||||
html_lang: str | None = None,
|
||||
html_custom_attrs: Optional[dict[str, Var | str]] = None,
|
||||
html_custom_attrs: dict[str, Var | str] | None = None,
|
||||
) -> Component:
|
||||
"""Create the document root.
|
||||
|
||||
|
@ -9,17 +9,7 @@ from abc import ABC, abstractmethod
|
||||
from functools import lru_cache, wraps
|
||||
from hashlib import md5
|
||||
from types import SimpleNamespace
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
ClassVar,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Sequence,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
from typing import Any, Callable, ClassVar, Iterator, List, Sequence, Type, Union
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
@ -238,7 +228,7 @@ class Component(BaseComponent, ABC):
|
||||
_memoization_mode: MemoizationMode = MemoizationMode()
|
||||
|
||||
# State class associated with this component instance
|
||||
State: Optional[Type[reflex.state.State]] = None
|
||||
State: Type[reflex.state.State] | None = None
|
||||
|
||||
def add_imports(self) -> ImportDict | list[ImportDict]:
|
||||
"""Add imports for the component.
|
||||
|
@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, ClassVar, List, Optional
|
||||
from typing import Any, Callable, ClassVar, List
|
||||
|
||||
from reflex.components.base.fragment import Fragment
|
||||
from reflex.components.component import (
|
||||
@ -197,7 +197,7 @@ class Upload(MemoizationLeaf):
|
||||
# The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as
|
||||
# values.
|
||||
# supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
||||
accept: Var[Optional[dict[str, List]]]
|
||||
accept: Var[dict[str, List] | None]
|
||||
|
||||
# Whether the dropzone is disabled.
|
||||
disabled: Var[bool]
|
||||
|
@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, Literal, Optional, TypedDict
|
||||
from typing import Any, Dict, Literal, TypedDict
|
||||
|
||||
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: list[int] | None
|
||||
|
||||
|
||||
class GridColumn(TypedDict):
|
||||
|
@ -118,7 +118,7 @@ class GroupHeaderClickedEventArgs(TypedDict):
|
||||
scrollEdge: tuple[int, int]
|
||||
|
||||
class GridCell(TypedDict):
|
||||
span: Optional[list[int]]
|
||||
span: list[int] | None
|
||||
|
||||
class GridColumn(TypedDict):
|
||||
title: str
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Style based on https://ui.shadcn.com/docs/components/drawer
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal, Optional
|
||||
from typing import Any, Literal
|
||||
|
||||
from reflex.components.component import Component, ComponentNamespace
|
||||
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
|
||||
@ -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[str | float]]
|
||||
snap_points: list[str | float] | None
|
||||
|
||||
# Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
|
||||
fade_from_index: Var[int]
|
||||
|
@ -17,7 +17,7 @@ rx.text(
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal, Optional, Union, get_args
|
||||
from typing import Any, Literal, Union, get_args
|
||||
|
||||
from reflex.components.component import BaseComponent
|
||||
from reflex.components.core.cond import Cond, color_mode_cond, cond
|
||||
@ -99,7 +99,7 @@ class ColorModeIconButton(IconButton):
|
||||
"""Icon Button for toggling light / dark mode via toggle_color_mode."""
|
||||
|
||||
# The position of the icon button. Follow document flow if None.
|
||||
position: Optional[Union[LiteralPosition, Var[LiteralPosition]]] = None
|
||||
position: Union[LiteralPosition, Var[LiteralPosition]] | None = None
|
||||
|
||||
# Allow picking the "system" value for the color mode.
|
||||
allow_system: bool = False
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, Optional, Union
|
||||
from typing import Literal
|
||||
|
||||
import reflex as rx
|
||||
from reflex.components.component import Component, ComponentNamespace
|
||||
@ -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[str | int | float | list | dict | bool | None]],
|
||||
**props,
|
||||
) -> Component:
|
||||
"""Create a radio group component.
|
||||
|
@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import enum
|
||||
from typing import Any, Dict, Literal, Optional, Union
|
||||
from typing import Any, Dict, Literal, Union
|
||||
|
||||
from reflex.base import Base
|
||||
from reflex.components.component import Component, NoSSRComponent
|
||||
@ -65,7 +65,7 @@ class EditorOptions(Base):
|
||||
rtl: bool | None = None
|
||||
|
||||
# List of buttons to use in the toolbar.
|
||||
button_list: Optional[list[Union[list[str], str]]]
|
||||
button_list: list[Union[list[str], str]] | None
|
||||
|
||||
|
||||
def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]:
|
||||
|
@ -42,7 +42,7 @@ class EditorOptions(Base):
|
||||
default_tag: str | None
|
||||
mode: str | None
|
||||
rtl: bool | None
|
||||
button_list: Optional[list[Union[list[str], str]]]
|
||||
button_list: list[Union[list[str], str]] | None
|
||||
|
||||
def on_blur_spec(e: Var, content: Var[str]) -> tuple[Var[str]]: ...
|
||||
def on_paste_spec(
|
||||
|
@ -23,7 +23,6 @@ from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Generic,
|
||||
Optional,
|
||||
TypeVar,
|
||||
get_args,
|
||||
get_origin,
|
||||
@ -789,7 +788,7 @@ class Config(Base):
|
||||
cors_allowed_origins: list[str] = ["*"]
|
||||
|
||||
# Tailwind config.
|
||||
tailwind: Optional[dict[str, Any]] = {"plugins": ["@tailwindcss/typography"]}
|
||||
tailwind: dict[str, Any] | None = {"plugins": ["@tailwindcss/typography"]}
|
||||
|
||||
# Timeout when launching the gunicorn server. TODO(rename this to backend_timeout?)
|
||||
timeout: int = 120
|
||||
|
@ -15,7 +15,6 @@ from typing import (
|
||||
Callable,
|
||||
Generic,
|
||||
List,
|
||||
Optional,
|
||||
Protocol,
|
||||
Sequence,
|
||||
Type,
|
||||
@ -341,7 +340,7 @@ class CallableEventSpec(EventSpec):
|
||||
API with functions that return a family of EventSpec.
|
||||
"""
|
||||
|
||||
fn: Optional[Callable[..., EventSpec]] = None
|
||||
fn: Callable[..., EventSpec] | None = None
|
||||
|
||||
def __init__(self, fn: Callable[..., EventSpec] | None = None, **kwargs):
|
||||
"""Initialize a CallableEventSpec.
|
||||
@ -394,7 +393,7 @@ class EventChain(EventActionsMixin):
|
||||
default_factory=list
|
||||
)
|
||||
|
||||
args_spec: Optional[Union[Callable, Sequence[Callable]]] = dataclasses.field(
|
||||
args_spec: Union[Callable, Sequence[Callable]] | None = dataclasses.field(
|
||||
default=None
|
||||
)
|
||||
|
||||
|
@ -23,7 +23,7 @@ import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, NamedTuple, Optional
|
||||
from typing import Any, Callable, NamedTuple
|
||||
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: list[str] | None = 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: list[str] | None = None
|
||||
):
|
||||
next_config = {
|
||||
"basePath": config.frontend_path or "",
|
||||
|
@ -28,7 +28,6 @@ from typing import (
|
||||
Literal,
|
||||
Mapping,
|
||||
NoReturn,
|
||||
Optional,
|
||||
ParamSpec,
|
||||
Sequence,
|
||||
Set,
|
||||
@ -1967,7 +1966,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[str | Var]] = None,
|
||||
deps: list[str | Var] | None = None,
|
||||
auto_deps: bool = True,
|
||||
interval: int | datetime.timedelta | None = None,
|
||||
backend: bool | None = None,
|
||||
@ -2562,7 +2561,7 @@ def computed_var(
|
||||
fget: None = None,
|
||||
initial_value: Any | types.Unset = types.Unset(),
|
||||
cache: bool = True,
|
||||
deps: Optional[list[str | Var]] = None,
|
||||
deps: list[str | Var] | None = None,
|
||||
auto_deps: bool = True,
|
||||
interval: datetime.timedelta | int | None = None,
|
||||
backend: bool | None = None,
|
||||
@ -2575,7 +2574,7 @@ def computed_var(
|
||||
fget: Callable[[BASE_STATE], RETURN_TYPE],
|
||||
initial_value: RETURN_TYPE | types.Unset = types.Unset(),
|
||||
cache: bool = True,
|
||||
deps: Optional[list[str | Var]] = None,
|
||||
deps: list[str | Var] | None = None,
|
||||
auto_deps: bool = True,
|
||||
interval: datetime.timedelta | int | None = None,
|
||||
backend: bool | None = None,
|
||||
@ -2587,7 +2586,7 @@ def computed_var(
|
||||
fget: Callable[[BASE_STATE], Any] | None = None,
|
||||
initial_value: Any | types.Unset = types.Unset(),
|
||||
cache: bool = True,
|
||||
deps: Optional[list[str | Var]] = None,
|
||||
deps: list[str | Var] | None = None,
|
||||
auto_deps: bool = True,
|
||||
interval: datetime.timedelta | int | None = None,
|
||||
backend: bool | None = None,
|
||||
|
@ -9,7 +9,6 @@ from typing import (
|
||||
Callable,
|
||||
Concatenate,
|
||||
Generic,
|
||||
Optional,
|
||||
ParamSpec,
|
||||
Protocol,
|
||||
Sequence,
|
||||
@ -242,7 +241,7 @@ class FunctionStringVar(FunctionVar[CALLABLE_TYPE]):
|
||||
class VarOperationCall(Generic[P, R], CachedVarOperation, Var[R]):
|
||||
"""Base class for immutable vars that are the result of a function call."""
|
||||
|
||||
_func: Optional[FunctionVar[ReflexCallable[P, R]]] = dataclasses.field(default=None)
|
||||
_func: FunctionVar[ReflexCallable[P, R]] | None = dataclasses.field(default=None)
|
||||
_args: tuple[Var | Any, ...] = dataclasses.field(default_factory=tuple)
|
||||
|
||||
@cached_property_no_lock
|
||||
|
Loading…
Reference in New Issue
Block a user