Skip to content

Commit a349831

Browse files
committed
Revert "Rename reactpy.web.export"
This reverts commit d8d0fd2.
1 parent d8d0fd2 commit a349831

File tree

5 files changed

+18
-60
lines changed

5 files changed

+18
-60
lines changed

src/build_scripts/copy_dir.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# dependencies = []
44
# ///
55

6+
# ruff: noqa: INP001
67
import logging
78
import shutil
89
import sys

src/reactpy/web/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from reactpy.web.module import (
22
export,
3-
import_components,
43
module_from_file,
54
module_from_string,
65
module_from_url,
76
)
87

98
__all__ = [
109
"export",
11-
"import_components",
1210
"module_from_file",
1311
"module_from_string",
1412
"module_from_url",

src/reactpy/web/module.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pathlib import Path
88
from typing import Any, NewType, overload
99

10-
from reactpy._warnings import warn
1110
from reactpy.config import REACTPY_DEBUG, REACTPY_WEB_MODULES_DIR
1211
from reactpy.core.vdom import Vdom
1312
from reactpy.types import ImportSourceDict, VdomConstructor
@@ -223,7 +222,7 @@ class WebModule:
223222

224223

225224
@overload
226-
def import_components(
225+
def export(
227226
web_module: WebModule,
228227
export_names: str,
229228
fallback: Any | None = ...,
@@ -232,15 +231,15 @@ def import_components(
232231

233232

234233
@overload
235-
def import_components(
234+
def export(
236235
web_module: WebModule,
237236
export_names: list[str] | tuple[str, ...],
238237
fallback: Any | None = ...,
239238
allow_children: bool = ...,
240239
) -> list[VdomConstructor]: ...
241240

242241

243-
def import_components(
242+
def export(
244243
web_module: WebModule,
245244
export_names: str | list[str] | tuple[str, ...],
246245
fallback: Any | None = None,
@@ -282,38 +281,6 @@ def import_components(
282281
]
283282

284283

285-
@overload
286-
def export(
287-
web_module: WebModule,
288-
export_names: str,
289-
fallback: Any | None = ...,
290-
allow_children: bool = ...,
291-
) -> VdomConstructor: ...
292-
293-
294-
@overload
295-
def export(
296-
web_module: WebModule,
297-
export_names: list[str] | tuple[str, ...],
298-
fallback: Any | None = ...,
299-
allow_children: bool = ...,
300-
) -> list[VdomConstructor]: ...
301-
302-
303-
def export(
304-
web_module: WebModule,
305-
export_names: str | list[str] | tuple[str, ...],
306-
fallback: Any | None = None,
307-
allow_children: bool = True,
308-
) -> VdomConstructor | list[VdomConstructor]:
309-
warn(
310-
"The 'export' function is deprecated and will be removed in a future release. "
311-
"Use 'import_components' instead.",
312-
DeprecationWarning,
313-
)
314-
return import_components(web_module, export_names, fallback, allow_children)
315-
316-
317284
def _make_export(
318285
web_module: WebModule,
319286
name: str,

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def pytest_addoption(parser: Parser) -> None:
3636

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

4242

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

5454

5555
@pytest.fixture(autouse=True, scope="function")

tests/test_web/test_module.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
async def test_that_js_module_unmount_is_called(display: DisplayFixture):
22-
SomeComponent = reactpy.web.import_components(
22+
SomeComponent = reactpy.web.export(
2323
reactpy.web.module_from_file(
2424
"set-flag-when-unmount-is-called",
2525
JS_FIXTURES_DIR / "set-flag-when-unmount-is-called.js",
@@ -52,7 +52,7 @@ def ShowCurrentComponent():
5252

5353

5454
async def test_module_from_url(browser):
55-
SimpleButton = reactpy.web.import_components(
55+
SimpleButton = reactpy.web.export(
5656
reactpy.web.module_from_url("/static/simple-button.js", resolve_exports=False),
5757
"SimpleButton",
5858
)
@@ -72,7 +72,7 @@ def ShowSimpleButton():
7272

7373

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

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

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

171171

172172
async def test_module_exports_multiple_components(display: DisplayFixture):
173-
Header1, Header2 = reactpy.web.import_components(
173+
Header1, Header2 = reactpy.web.export(
174174
reactpy.web.module_from_file(
175175
"exports-two-components", JS_FIXTURES_DIR / "exports-two-components.js"
176176
),
@@ -190,7 +190,7 @@ async def test_imported_components_can_render_children(display: DisplayFixture):
190190
module = reactpy.web.module_from_file(
191191
"component-can-have-child", JS_FIXTURES_DIR / "component-can-have-child.js"
192192
)
193-
Parent, Child = reactpy.web.import_components(module, ["Parent", "Child"])
193+
Parent, Child = reactpy.web.export(module, ["Parent", "Child"])
194194

195195
await display.show(
196196
lambda: Parent(
@@ -222,7 +222,7 @@ async def test_keys_properly_propagated(display: DisplayFixture):
222222
module = reactpy.web.module_from_file(
223223
"keys-properly-propagated", JS_FIXTURES_DIR / "keys-properly-propagated.js"
224224
)
225-
GridLayout = reactpy.web.import_components(module, "GridLayout")
225+
GridLayout = reactpy.web.export(module, "GridLayout")
226226

227227
await display.show(
228228
lambda: GridLayout(
@@ -277,7 +277,7 @@ async def test_subcomponent_notation_as_str_attrs(display: DisplayFixture):
277277
"subcomponent-notation",
278278
JS_FIXTURES_DIR / "subcomponent-notation.js",
279279
)
280-
InputGroup, InputGroupText, FormControl, FormLabel = reactpy.web.import_components(
280+
InputGroup, InputGroupText, FormControl, FormLabel = reactpy.web.export(
281281
module, ["InputGroup", "InputGroup.Text", "Form.Control", "Form.Label"]
282282
)
283283

@@ -337,7 +337,7 @@ async def test_subcomponent_notation_as_obj_attrs(display: DisplayFixture):
337337
"subcomponent-notation",
338338
JS_FIXTURES_DIR / "subcomponent-notation.js",
339339
)
340-
InputGroup, Form = reactpy.web.import_components(module, ["InputGroup", "Form"])
340+
InputGroup, Form = reactpy.web.export(module, ["InputGroup", "Form"])
341341

342342
content = reactpy.html.div(
343343
{"id": "the-parent"},
@@ -394,7 +394,7 @@ async def test_callable_prop_with_javacript(display: DisplayFixture):
394394
module = reactpy.web.module_from_file(
395395
"callable-prop", JS_FIXTURES_DIR / "callable-prop.js"
396396
)
397-
Component = reactpy.web.import_components(module, "Component")
397+
Component = reactpy.web.export(module, "Component")
398398

399399
@reactpy.component
400400
def App():
@@ -415,11 +415,3 @@ def test_module_from_string():
415415
reactpy.web.module_from_string("temp", "old")
416416
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
417417
reactpy.web.module_from_string("temp", "new")
418-
419-
420-
def test_deprecated_export():
421-
module = reactpy.web.module_from_string(
422-
"temp", "export function Component() { return 'hello' }"
423-
)
424-
with pytest.warns(DeprecationWarning, match="The 'export' function is deprecated"):
425-
reactpy.web.export(module, "Component")

0 commit comments

Comments
 (0)