Skip to content
Merged
Show file tree
Hide file tree
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
Revert "Rename reactpy.web.export"
This reverts commit d8d0fd2.
  • Loading branch information
Archmonger committed Dec 7, 2025
commit a34983196923e845a97e245c5d8696067c05a223
1 change: 1 addition & 0 deletions src/build_scripts/copy_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# dependencies = []
# ///

# ruff: noqa: INP001
import logging
import shutil
import sys
Expand Down
2 changes: 0 additions & 2 deletions src/reactpy/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from reactpy.web.module import (
export,
import_components,
module_from_file,
module_from_string,
module_from_url,
)

__all__ = [
"export",
"import_components",
"module_from_file",
"module_from_string",
"module_from_url",
Expand Down
39 changes: 3 additions & 36 deletions src/reactpy/web/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pathlib import Path
from typing import Any, NewType, overload

from reactpy._warnings import warn
from reactpy.config import REACTPY_DEBUG, REACTPY_WEB_MODULES_DIR
from reactpy.core.vdom import Vdom
from reactpy.types import ImportSourceDict, VdomConstructor
Expand Down Expand Up @@ -223,7 +222,7 @@ class WebModule:


@overload
def import_components(
def export(
web_module: WebModule,
export_names: str,
fallback: Any | None = ...,
Expand All @@ -232,15 +231,15 @@ def import_components(


@overload
def import_components(
def export(
web_module: WebModule,
export_names: list[str] | tuple[str, ...],
fallback: Any | None = ...,
allow_children: bool = ...,
) -> list[VdomConstructor]: ...


def import_components(
def export(
web_module: WebModule,
export_names: str | list[str] | tuple[str, ...],
fallback: Any | None = None,
Expand Down Expand Up @@ -282,38 +281,6 @@ def import_components(
]


@overload
def export(
web_module: WebModule,
export_names: str,
fallback: Any | None = ...,
allow_children: bool = ...,
) -> VdomConstructor: ...


@overload
def export(
web_module: WebModule,
export_names: list[str] | tuple[str, ...],
fallback: Any | None = ...,
allow_children: bool = ...,
) -> list[VdomConstructor]: ...


def export(
web_module: WebModule,
export_names: str | list[str] | tuple[str, ...],
fallback: Any | None = None,
allow_children: bool = True,
) -> VdomConstructor | list[VdomConstructor]:
warn(
"The 'export' function is deprecated and will be removed in a future release. "
"Use 'import_components' instead.",
DeprecationWarning,
)
return import_components(web_module, export_names, fallback, allow_children)


def _make_export(
web_module: WebModule,
name: str,
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def pytest_addoption(parser: Parser) -> None:

@pytest.fixture(autouse=True, scope="session")
def install_playwright():
subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607
subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607
subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607, S603
subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607, S603


@pytest.fixture(autouse=True, scope="session")
Expand All @@ -49,7 +49,7 @@ def rebuild():
# passed to the subprocess.
env = os.environ.copy()
env.pop("HATCH_ENV_ACTIVE", None)
subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607
subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607, S603


@pytest.fixture(autouse=True, scope="function")
Expand Down
30 changes: 11 additions & 19 deletions tests/test_web/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


async def test_that_js_module_unmount_is_called(display: DisplayFixture):
SomeComponent = reactpy.web.import_components(
SomeComponent = reactpy.web.export(
reactpy.web.module_from_file(
"set-flag-when-unmount-is-called",
JS_FIXTURES_DIR / "set-flag-when-unmount-is-called.js",
Expand Down Expand Up @@ -52,7 +52,7 @@ def ShowCurrentComponent():


async def test_module_from_url(browser):
SimpleButton = reactpy.web.import_components(
SimpleButton = reactpy.web.export(
reactpy.web.module_from_url("/static/simple-button.js", resolve_exports=False),
"SimpleButton",
)
Expand All @@ -72,7 +72,7 @@ def ShowSimpleButton():


async def test_module_from_file(display: DisplayFixture):
SimpleButton = reactpy.web.import_components(
SimpleButton = reactpy.web.export(
reactpy.web.module_from_file(
"simple-button", JS_FIXTURES_DIR / "simple-button.js"
),
Expand Down Expand Up @@ -163,14 +163,14 @@ def test_module_missing_exports():
module = WebModule("test", NAME_SOURCE, None, {"a", "b", "c"}, None, False)

with pytest.raises(ValueError, match="does not export 'x'"):
reactpy.web.import_components(module, "x")
reactpy.web.export(module, "x")

with pytest.raises(ValueError, match=r"does not export \['x', 'y'\]"):
reactpy.web.import_components(module, ["x", "y"])
reactpy.web.export(module, ["x", "y"])


async def test_module_exports_multiple_components(display: DisplayFixture):
Header1, Header2 = reactpy.web.import_components(
Header1, Header2 = reactpy.web.export(
reactpy.web.module_from_file(
"exports-two-components", JS_FIXTURES_DIR / "exports-two-components.js"
),
Expand All @@ -190,7 +190,7 @@ async def test_imported_components_can_render_children(display: DisplayFixture):
module = reactpy.web.module_from_file(
"component-can-have-child", JS_FIXTURES_DIR / "component-can-have-child.js"
)
Parent, Child = reactpy.web.import_components(module, ["Parent", "Child"])
Parent, Child = reactpy.web.export(module, ["Parent", "Child"])

await display.show(
lambda: Parent(
Expand Down Expand Up @@ -222,7 +222,7 @@ async def test_keys_properly_propagated(display: DisplayFixture):
module = reactpy.web.module_from_file(
"keys-properly-propagated", JS_FIXTURES_DIR / "keys-properly-propagated.js"
)
GridLayout = reactpy.web.import_components(module, "GridLayout")
GridLayout = reactpy.web.export(module, "GridLayout")

await display.show(
lambda: GridLayout(
Expand Down Expand Up @@ -277,7 +277,7 @@ async def test_subcomponent_notation_as_str_attrs(display: DisplayFixture):
"subcomponent-notation",
JS_FIXTURES_DIR / "subcomponent-notation.js",
)
InputGroup, InputGroupText, FormControl, FormLabel = reactpy.web.import_components(
InputGroup, InputGroupText, FormControl, FormLabel = reactpy.web.export(
module, ["InputGroup", "InputGroup.Text", "Form.Control", "Form.Label"]
)

Expand Down Expand Up @@ -337,7 +337,7 @@ async def test_subcomponent_notation_as_obj_attrs(display: DisplayFixture):
"subcomponent-notation",
JS_FIXTURES_DIR / "subcomponent-notation.js",
)
InputGroup, Form = reactpy.web.import_components(module, ["InputGroup", "Form"])
InputGroup, Form = reactpy.web.export(module, ["InputGroup", "Form"])

content = reactpy.html.div(
{"id": "the-parent"},
Expand Down Expand Up @@ -394,7 +394,7 @@ async def test_callable_prop_with_javacript(display: DisplayFixture):
module = reactpy.web.module_from_file(
"callable-prop", JS_FIXTURES_DIR / "callable-prop.js"
)
Component = reactpy.web.import_components(module, "Component")
Component = reactpy.web.export(module, "Component")

@reactpy.component
def App():
Expand All @@ -415,11 +415,3 @@ def test_module_from_string():
reactpy.web.module_from_string("temp", "old")
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
reactpy.web.module_from_string("temp", "new")


def test_deprecated_export():
module = reactpy.web.module_from_string(
"temp", "export function Component() { return 'hello' }"
)
with pytest.warns(DeprecationWarning, match="The 'export' function is deprecated"):
reactpy.web.export(module, "Component")