fix pyi file
This commit is contained in:
parent
98ade6a197
commit
e88aa8257b
@ -5,11 +5,19 @@
|
|||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
from typing import Any, Dict, Optional, Union, overload
|
from typing import Any, Dict, Optional, Union, overload
|
||||||
|
|
||||||
|
from typing_extensions import TypedDict
|
||||||
|
|
||||||
from reflex.components.component import NoSSRComponent
|
from reflex.components.component import NoSSRComponent
|
||||||
from reflex.event import EventType
|
from reflex.event import EventType
|
||||||
from reflex.style import Style
|
from reflex.style import Style
|
||||||
from reflex.vars.base import Var
|
from reflex.vars.base import Var
|
||||||
|
|
||||||
|
class Progress(TypedDict):
|
||||||
|
played: float
|
||||||
|
playedSeconds: float
|
||||||
|
loaded: float
|
||||||
|
loadedSeconds: float
|
||||||
|
|
||||||
class ReactPlayer(NoSSRComponent):
|
class ReactPlayer(NoSSRComponent):
|
||||||
@overload
|
@overload
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -39,7 +47,7 @@ class ReactPlayer(NoSSRComponent):
|
|||||||
on_context_menu: Optional[EventType[[]]] = None,
|
on_context_menu: Optional[EventType[[]]] = None,
|
||||||
on_disable_pip: Optional[EventType[[]]] = None,
|
on_disable_pip: Optional[EventType[[]]] = None,
|
||||||
on_double_click: Optional[EventType[[]]] = None,
|
on_double_click: Optional[EventType[[]]] = None,
|
||||||
on_duration: Optional[EventType] = None,
|
on_duration: Optional[EventType[float]] = None,
|
||||||
on_enable_pip: Optional[EventType[[]]] = None,
|
on_enable_pip: Optional[EventType[[]]] = None,
|
||||||
on_ended: Optional[EventType[[]]] = None,
|
on_ended: Optional[EventType[[]]] = None,
|
||||||
on_error: Optional[EventType[[]]] = None,
|
on_error: Optional[EventType[[]]] = None,
|
||||||
@ -56,10 +64,10 @@ class ReactPlayer(NoSSRComponent):
|
|||||||
on_play: Optional[EventType[[]]] = None,
|
on_play: Optional[EventType[[]]] = None,
|
||||||
on_playback_quality_change: Optional[EventType[[]]] = None,
|
on_playback_quality_change: Optional[EventType[[]]] = None,
|
||||||
on_playback_rate_change: Optional[EventType[[]]] = None,
|
on_playback_rate_change: Optional[EventType[[]]] = None,
|
||||||
on_progress: Optional[EventType] = None,
|
on_progress: Optional[EventType[Progress]] = None,
|
||||||
on_ready: Optional[EventType[[]]] = None,
|
on_ready: Optional[EventType[[]]] = None,
|
||||||
on_scroll: Optional[EventType[[]]] = None,
|
on_scroll: Optional[EventType[[]]] = None,
|
||||||
on_seek: Optional[EventType] = None,
|
on_seek: Optional[EventType[float]] = None,
|
||||||
on_start: Optional[EventType[[]]] = None,
|
on_start: Optional[EventType[[]]] = None,
|
||||||
on_unmount: Optional[EventType[[]]] = None,
|
on_unmount: Optional[EventType[[]]] = None,
|
||||||
**props,
|
**props,
|
||||||
|
@ -16,7 +16,7 @@ from itertools import chain
|
|||||||
from multiprocessing import Pool, cpu_count
|
from multiprocessing import Pool, cpu_count
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType, SimpleNamespace
|
from types import ModuleType, SimpleNamespace
|
||||||
from typing import Any, Callable, Iterable, Type, get_args
|
from typing import Any, Callable, Iterable, Type, get_args, get_origin
|
||||||
|
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
from reflex.utils import types as rx_types
|
from reflex.utils import types as rx_types
|
||||||
@ -430,13 +430,28 @@ def _generate_component_create_functiondef(
|
|||||||
def figure_out_return_type(annotation: Any):
|
def figure_out_return_type(annotation: Any):
|
||||||
if inspect.isclass(annotation) and issubclass(annotation, inspect._empty):
|
if inspect.isclass(annotation) and issubclass(annotation, inspect._empty):
|
||||||
return ast.Name(id="Optional[EventType]")
|
return ast.Name(id="Optional[EventType]")
|
||||||
|
|
||||||
|
if not isinstance(annotation, str) and get_origin(annotation) is tuple:
|
||||||
|
arguments = get_args(annotation)
|
||||||
|
|
||||||
|
arguments_without_var = [
|
||||||
|
get_args(argument)[0] if get_origin(argument) == Var else argument
|
||||||
|
for argument in arguments
|
||||||
|
]
|
||||||
|
|
||||||
|
return ast.Name(
|
||||||
|
id=f"Optional[EventType[{', '.join(
|
||||||
|
[arg.__name__ for arg in arguments_without_var]
|
||||||
|
)}]]"
|
||||||
|
)
|
||||||
|
|
||||||
if isinstance(annotation, str) and annotation.startswith("Tuple["):
|
if isinstance(annotation, str) and annotation.startswith("Tuple["):
|
||||||
inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]")
|
inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]")
|
||||||
|
|
||||||
if inside_of_tuple == "()":
|
if inside_of_tuple == "()":
|
||||||
return ast.Name(id="Optional[EventType[[]]]")
|
return ast.Name(id="Optional[EventType[[]]]")
|
||||||
|
|
||||||
arguments: list[str] = [""]
|
arguments = [""]
|
||||||
|
|
||||||
bracket_count = 0
|
bracket_count = 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user