Skip to content

Commit d53576b

Browse files
committed
Move pyscript code into reactpy.executors.pyscript
1 parent 5677c6f commit d53576b

File tree

12 files changed

+29
-31
lines changed

12 files changed

+29
-31
lines changed

src/reactpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use_state,
2020
)
2121
from reactpy.core.vdom import Vdom
22-
from reactpy.pyscript.components import pyscript_component
22+
from reactpy.executors.pyscript.components import pyscript_component
2323
from reactpy.utils import Ref, reactpy_to_string, string_to_reactpy
2424

2525
__author__ = "The Reactive Python Team"

src/reactpy/core/_thread_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class ThreadLocal(Generic[_StateType]): # nocov
1010
"""Utility for managing per-thread state information. This is only used in
11-
environments where ContextVars are not available, such as the `pyodide`
11+
environments where ContextVars are not available, such as the `pyscript`
1212
executor."""
1313

1414
def __init__(self, default: Callable[[], _StateType]):

src/reactpy/core/hooks.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ def __init__(
8484
self,
8585
initial_value: _Type | Callable[[], _Type],
8686
) -> None:
87-
if callable(initial_value):
88-
self.value = initial_value()
89-
else:
90-
self.value = initial_value
91-
87+
self.value = initial_value() if callable(initial_value) else initial_value
9288
hook = HOOK_STACK.current_hook()
9389

9490
def dispatch(new: _Type | Callable[[_Type], _Type]) -> None:
@@ -434,10 +430,7 @@ def use_callback(
434430
def setup(function: _CallbackFunc) -> _CallbackFunc:
435431
return memoize(lambda: function)
436432

437-
if function is not None:
438-
return setup(function)
439-
else:
440-
return setup
433+
return setup(function) if function is not None else setup
441434

442435

443436
class _LambdaCaller(Protocol):
@@ -553,17 +546,16 @@ def _try_to_infer_closure_values(
553546
func: Callable[..., Any] | None,
554547
values: Sequence[Any] | ellipsis | None,
555548
) -> Sequence[Any] | None:
556-
if values is ...:
557-
if isinstance(func, FunctionType):
558-
return (
559-
[cell.cell_contents for cell in func.__closure__]
560-
if func.__closure__
561-
else []
562-
)
563-
else:
564-
return None
565-
else:
549+
if values is not ...:
566550
return values
551+
if isinstance(func, FunctionType):
552+
return (
553+
[cell.cell_contents for cell in func.__closure__]
554+
if func.__closure__
555+
else []
556+
)
557+
else:
558+
return None
567559

568560

569561
def strictly_equal(x: Any, y: Any) -> bool:

src/reactpy/executors/asgi/pyscript.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
from reactpy.executors.asgi.middleware import ReactPyMiddleware
1414
from reactpy.executors.asgi.standalone import ReactPy, ReactPyApp
1515
from reactpy.executors.asgi.types import AsgiWebsocketScope
16+
from reactpy.executors.pyscript.utils import (
17+
pyscript_component_html,
18+
pyscript_setup_html,
19+
)
1620
from reactpy.executors.utils import vdom_head_to_html
17-
from reactpy.pyscript.utils import pyscript_component_html, pyscript_setup_html
1821
from reactpy.types import ReactPyConfig, VdomDict
1922

2023

src/reactpy/executors/asgi/standalone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
AsgiV3WebsocketApp,
2424
AsgiWebsocketScope,
2525
)
26+
from reactpy.executors.pyscript.utils import pyscript_setup_html
2627
from reactpy.executors.utils import server_side_component_html, vdom_head_to_html
27-
from reactpy.pyscript.utils import pyscript_setup_html
2828
from reactpy.types import (
2929
PyScriptOptions,
3030
ReactPyConfig,
File renamed without changes.

src/reactpy/pyscript/component_template.py renamed to src/reactpy/executors/pyscript/component_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# type: ignore
33
import asyncio
44

5-
from reactpy.pyscript.layout_handler import ReactPyLayoutHandler
5+
from reactpy.executors.pyscript.layout_handler import ReactPyLayoutHandler
66

77

88
# User component is inserted below by regex replacement

src/reactpy/pyscript/components.py renamed to src/reactpy/executors/pyscript/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
from reactpy import component, hooks
7-
from reactpy.pyscript.utils import pyscript_component_html
7+
from reactpy.executors.pyscript.utils import pyscript_component_html
88
from reactpy.types import Component, Key
99
from reactpy.utils import string_to_reactpy
1010

File renamed without changes.

0 commit comments

Comments
 (0)